同様の質問があることは承知していますが、回答は私の場合に役立つほど具体的ではありませんでした。
Tiled で作成し、pytmx を使用して Pygame にアップロードしたタイル マップを表示できるプログラムを作成しようとしています。私が抱えている唯一の問題は、Pygame の画面に画像をブリットすることです。
これは私が受け取り続けるエラーです: Traceback (most recent call last): File "C:\Users\b\Desktop\Frozen Map Textures\test.py", line 32, in screen.blit(images[i],( x*32,y*32)) TypeError: 引数 1 は、None ではなく pygame.Surface でなければなりません
誰かが問題を解決する方法を知っていれば、私はとても感謝しています! ご助力いただきありがとうございます!
コードは以下のとおりです。
import pygame
from pytmx import load_pygame
import random
white = (255,255,255)
#create window
screenSize = (800,600)
screen = pygame.display.set_mode(screenSize)
pygame.display.set_caption("GameName")
screen.fill(white)
gameMap = load_pygame("Frozen.tmx")
#creates list of single tiles in first layer
images = []
for y in range(50):
for x in range(50):
image = gameMap.get_tile_image(x,y,0)
images.append(image)
#displays tiles in locations
i = 0
for y in range(50):
for x in range(50):
screen.blit(images[i],(x*32,y*32))
i += 1
#main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()
pygame.quit()