Ejemplo n.º 1
0
 def updateEnemyBoats(self):
     #Update and delete animations
     for i in reversed(range(len(self.enemy_boats))):
         #Check if the boat is ready to delete
         if self.enemy_boats[i].deleteMe():
             del self.enemy_boats[i]
             continue
         self.enemy_boats[i].update(self.water_heights)
         #Check for shooting and collisions if the boat is not dead
         if not self.enemy_boats[i].isDead():
             #Determine if the boat should shoot
             if self.enemy_boats[i].readyToShoot():
                 self.enemy_boats[i].shoot()
                 self.shoot(self.enemy_boats[i], False)
             #Check for collisions with cannonballs
             for j in reversed(range(len(self.cannonballs))):
                 x, y = self.enemy_boats[i].getCenter()
                 if self.cannonballs[j].damage_delay < 0 and distance(
                         x, y, self.cannonballs[j].x,
                         self.cannonballs[j].y) < rum_collision_distance:
                     a = animation.AnimatedSprite(self.cannonballs[j].x,
                                                  self.cannonballs[j].y, 0,
                                                  0, self.explosion_frames,
                                                  blast_dwell_sequence)
                     self.animations.append(a)
                     del self.cannonballs[j]
                     self.enemy_boats[i].health -= 1
                     #Begin the death animation
                     if self.enemy_boats[i].isDead():
                         self.enemy_boats[i].jump()
Ejemplo n.º 2
0
 def shoot(self, ship, direction_right):
     x,y = ship.getCenter()
     angle = -(math.pi/180)*ship.angle-cannon_ball_arc
     if not direction_right:
         angle = math.pi-angle+cannon_ball_arc
     ball = cannon_ball.CannonBall(x,y,math.cos(angle)*cannon_ball_speed,math.sin(angle)*cannon_ball_speed)
     self.cannonballs.append(ball)
     a = animation.AnimatedSprite(x,y, smoke_dx,0,self.explosion_frames, dwell_sequence)
     self.animations.append(a)
Ejemplo n.º 3
0
 def updateEnemyBoats(self):
     #Update and delete animations
     for i in reversed(range(len(self.enemy_boats))):
         self.enemy_boats[i].update(self.water_heights)
         #Check for collisions with cannonballs
         for j in reversed(range(len(self.cannonballs))):
             x,y = self.enemy_boats[i].getCenter()
             if distance(x,y,self.cannonballs[j].x,self.cannonballs[j].y) < rum_collision_distance:
                 a = animation.AnimatedSprite(self.cannonballs[j].x,self.cannonballs[j].y,
                             0,0,self.explosion_frames, blast_dwell_sequence)
                 self.animations.append(a)
                 del self.cannonballs[j]
Ejemplo n.º 4
0
 def checkCollisions(self, player):
     x, y = player.getCenter()
     #Check to see if the player collides with any of the pickups
     for i in reversed(range(len(self.pickups))):
         if distance(x, y, self.pickups[i][0],
                     self.pickups[i][1]) < rum_collision_distance:
             if self.pickups[i][3] == 'rum':
                 self.points += 1
             else:
                 self.lives -= 1
             del self.pickups[i]
     #Check for collisions with cannonballs
     for j in reversed(range(len(self.cannonballs))):
         if self.cannonballs[j].damage_delay < 0 and distance(
                 x, y, self.cannonballs[j].x,
                 self.cannonballs[j].y) < rum_collision_distance:
             a = animation.AnimatedSprite(self.cannonballs[j].x,
                                          self.cannonballs[j].y, 0, 0,
                                          self.explosion_frames,
                                          blast_dwell_sequence)
             self.animations.append(a)
             del self.cannonballs[j]
             self.lives -= 1