当一个敌人被杀死而另一个敌人被杀死时,我该如何解决这个问题?



>视频 当我杀死其中一个敌人时,他们都 dispear 我不知道为什么在我的代码上我告诉它只制作 1 个 dispear,但它不起作用。


# enemys 2
for enemyshoot in enemyshooting: # all enemys stored in a list
for bullet in bullets: # player bullets
if bullet.rect.colliderect(enemyshoot.hitbox): # if collid with the enemys hitbox
if enemyshoot.health > -8: # if the health isnt greater then -1
enemyshoot.health -= 1 # keep removing its health
bullets.pop(bullets.index(bullet)) # pop enemys bullet if collided with enemy
hitesound.play() # sound
# this function calss the -5 text appearing and dispearing on my screen
minusenemyhealthtext()
else:
for rmv1 in range(len(enemyshooting)-1,-1,-1): 
del enemyshooting[one]


# enemys 2
for enemyshoot in enemyshooting:
for bullet in bullets:
if bullet.rect.colliderect(enemyshoot.hitbox):
if enemyshoot.health > -8:
enemyshoot.health -= 1
bullets.pop(bullets.index(bullet))
else:
del enemyshooting[one]

相关内容

最新更新