我有一个游戏我正在制作但由于某种原因敌人,当它下降它应该开始上升,但它没有。它刚开始眨眼。 代码:
import pygame
pygame.init()
window = pygame.display.set_mode((800,800))
pygame.display.set_caption("Yues")
theboard = pygame.image.load('theboard.png')
enemy = pygame.image.load('mrenemy.png')
mrhinckleberg = pygame.image.load('MrHinckleBerg.png')
mrhincklebergdead = pygame.image.load('MrHinckleBergdead.png')
black = (0,0,0)
def quitt():
pygame.quit()
quit()
enemydirection = 'down'
enemyx = 500
enemyy = 50
while True:
window.blit(theboard, (0,0))
if enemydirection == 'down':
enemyy += 60
if enemyy >= 790:
enemydirection = 'up'
elif enemydirection == 'up':
enemyy -= 60
if enemyy >= 10:
enemydirection = 'down'
for event in pygame.event.get():
if event.type == pygame.QUIT:
答案 0 :(得分:1)
错误在您的上边界检测中。变化
if enemyy >= 10:
到
if enemyy <= 10: