我更改了敌人的路径,但是在1次尝试后游戏显示变黑,然后我将敌人的路径恢复为正常,但随后我的角色无法移动... pygame或pycharm
我试图多次按“ Ctrl + z”,但是它也没有起作用。
我的移动代码:
if keys[pygame.K_LEFT] and man.x > man.vel:
man.x -= man.vel
man.left = True
man.right = False
man.standing = False
elif keys[pygame.K_RIGHT] and man.x < 500 - man.width - man.vel:
man.x += man.vel
man.right = True
man.left = False
man.standing = False
else:
man.standing = True
man.walkCount = 0
if not (man.isJump):
if keys[pygame.K_UP]:
man.isJump = True
man.right = False
man.left = False
man.walkCount = 0
else:
if man.jumpCount >= -10:
neg = 1
if man.jumpCount < 0:
neg = -1
man.y -= (man.jumpCount ** 2) * 0.5 * neg
man.jumpCount -= 1
else:
man.isJump = False
man.jumpCount = 10
man.jumpCount = 10
完整的代码,您可以在这里看到:
主要:https://pastebin.com/pHgtUi5F
玩家:https://pastebin.com/C4kmU2Rn
答案 0 :(得分:0)
好了,它开始起作用了...因此,我在主循环中添加了keys = pygame.key.get_pressed()
,然后从{{删除了if K_LEFT
,if K_RIGHT
等... 1}},所以我的步行代码如下:
if K_SPACE