我正在为Python游戏编写代码,我有以下内容
WIDTH = 600
HEIGHT = 800
player_x = 600
player_y = 350
def draw():
screen.blit(images.backdrop, (0, 0))
screen.blit(images.mars, (50, 50))
screen.blit(images.astronaut, (player_x, player_y))
screen.blit(images.ship, (550, 300))
def game_loop():
global player_x, player_y
if keyboard.right:
player_x += 5
elif keyboard.left:
player_x -= 5
elif keyboard.up:
player_y -= 5
elif keyboard.down:
player_y += 5
clock.schedule_interval(game_loop, 0.03)
然而,当我运行它时,它不会显示宇航员。我有宇航员的形象,但无论我做什么,它都不会起作用。有人能告诉我问题出在哪里吗
传递给^{} 的坐标是曲面左上角的位置。由于曲面的宽度为600,x坐标为600,因此窗口外的曲面位于右侧。
您可以切换宇航员的x坐标,但最有可能切换窗口的
WIDTH
和HEIGHT
:WIDTH = 600
HEIGHT = 800
相关问题 更多 >
编程相关推荐