python+pygame+pytmx+map editor开发一个tiled游戏demo 01显示玩家
显示玩家
import pygame
if __name__ == '__main__':
pygame.init()
# 设置窗口大小
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 640
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Pytmx Demo")
player_x = 50
player_y = 50
player_speed = 0.3 # 玩家速度
# 游戏主循环
running = True
while running:
screen.fill((0, 0, 0)) # 填充背景色
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.draw.rect(screen, (255, 0, 0), pygame.Rect(player_x, player_y, 32, 32)) # 32x32 是玩家的大小
pygame.display.flip() # 更新显示
pygame.quit()
原文地址:https://blog.csdn.net/douyh/article/details/145259925
免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!