03 Mar Aurora Saturday 13:00 Python Practice 02.27.
Posted at 19:20h in Uncategorized 0 Comments
Since we have changed isKilled() method in the Enemy as following code:
def isKilled(self): if self.hp <= 0: return True else: return False
Modify the following program we made in the class, so the enemy will be destroyed:
for w in weapons: w.update() screen.blit(w.image, w.rect) hitList = pygame.sprite.spritecollide(w, enemies, False) if len(hitList) > 0: damage = w.getDamage() for enemy in hitList: enemy.gotShot(damage) enemy.isKilled() # Hint: this line need to be modified w.kill()
and we have created explos sprite group. Try to add an explosion object to the explos sprite group after every enemy has been killed and use for loop to update and blit every explosion object.
Sorry, the comment form is closed at this time.