Как это исправить, если один враг убит, а остальные исчезнут? - PullRequest
0 голосов
/ 21 июня 2020

ВИДЕО на одном видео, когда я убиваю одного из врагов, они все исчезают, я не знаю, почему в моем коде я сказал ему сделать только 1 исчезновение, но оно не работает.


                # 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]




1 Ответ

0 голосов
/ 21 июня 2020
            # 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]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...