예제 #1
0
    def generate_missile(self):
        p = projectiles.Missile(position=(uniform(-500,
                                                  self.resolution[0] + 500),
                                          -50),
                                velocity=(uniform(-3, 3), uniform(2, 7)))

        count = 0
        while p.position[1] < -20 and count < 100:
            p.apply_physics(self.physics, self.buildings)
            count += 1

        return p
예제 #2
0
 def apply_physics(self):    
     self.ticks_since_firing += 1    
     
     # must have support
     if not self.destroyed:
         if not self.game.buildings.get(self.centre[0], self.centre[1]):
             self.destroyed = True            
             explosion = projectiles.Missile(self.centre, (0, 0), 0.)
             explosion.exploding = True
             explosion.blast_colour_a = (100, 200, 150)
             explosion.blast_colour_b = (20, 50, 20) 
             explosion.blast_radius = self.length
             explosion.blast_ticks = 30 
             self.game.projectiles.append(explosion)
예제 #3
0
    def generate_missile(self):
        spawn_pos = (uniform(0, self.resolution[0]), 0)
        ground_target = (uniform(0, self.resolution[0]), self.resolution[1])

        p = projectiles.Missile(position=spawn_pos,
                                target=ground_target,
                                velocity=1.)

        count = 0
        while p.position[1] < -20 and count < 100:
            p.apply_physics(self.physics, self.buildings)
            count += 1

        return p
예제 #4
0
    def update(self):
        super().update()

        self.count += 1

        self.move(0, 1)

        if random.randint(0, self.bullet_chance) == 0 and self.count > 120:
            self.count = 0
            if self.launches_missile:
                projectiles.Missile(self.x + self.image.get_width() / 2,
                                    self.y + self.image.get_height(), True)
            else:
                projectiles.Bullet(self.x + self.image.get_width() / 2,
                                   self.y + self.image.get_height(), True)
예제 #5
0
 def shoot(self, x, y):
     return projectiles.Missile(x, y, False)