youtubeで動画を見ながらテトリスを作っていました。そうすると、見慣れないエラーが出てきました。
#コード
python3
1import pygame 2from pygame.locals import * 3import sys 4import random 5import copy 6 7window_size = 640, 480 8nminocell = 7 9 10def main(): 11 12 pygame.init() 13 screen = pygame.display.set_mode(window_size) 14 pygame.display.set_caption("Tetris") 15 image =pygame.image.load("./tile.png") 16 cellimage = [] 17 for i in range(nminocell): 18 temp_surface = pygame.Surface((40, 40)) 19 temp_surface_dest = pygame.Surface((20, 20)) 20 temp_surface.blit(image, (0, 0), (40*i, 0, 40, 40)) 21 pygame.transform.scale(temp_surface, (20, 20), temp_surface_dest) 22 cellimage.append(temp_surface_dest) 23 del temp_surface_dest 24 25 nnumber = 0 26 while True: 27 for event in pygame.event.get(): 28 if event.type == QUIT: 29 pygame.quit() 30 sys.exit() 31 if event.type == KEYDOWN: 32 if event.key == K_SPACE: 33 screen.blit(cellimage[nnumber], (0, 0, 20, 20)) 34 nnumber = (nnumber + 1) % nminocell 35 36 37 screen.blit(cellimage, (0, 0, 20, 20)) 38 pygame.display.update() 39 40if __name__ == "__main__": 41 main()
#動画のURL
見ていた動画
#エラーコード
pygame
1Hello from the pygame community. https://www.pygame.org/contribute.html 2Traceback (most recent call last): 3 File "tetris.py", line 41, in <module> 4 main() 5 File "tetris.py", line 37, in main 6 screen.blit(cellimage, (0, 0, 20, 20)) 7TypeError: argument 1 must be pygame.Surface, not list
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/02 08:50