TORONTO KIDS COMPUTER CLUB | Aurora Saturday 13:00 Python Practice 02.27.
19117
post-template-default,single,single-post,postid-19117,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Aurora Saturday 13:00 Python Practice 02.27.

03 Mar Aurora Saturday 13:00 Python Practice 02.27.

Question:
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.


No Comments

Sorry, the comment form is closed at this time.