Ejemplo n.º 1
0
 def spawn_asteroid(self, dt):
     #[obj for obj in self.game_objects if isinstance(obj, entities.Asteroid)]
     if len([obj for obj in self.game_objects if isinstance(obj, entities.Asteroid)]) < 20:
         size = uniform(0.8, 1.0)
         x, y = self.player.x, self.player.y
         while distance((x, y), (self.player.x, self.player.y)) < 100:
             x = uniform(-window_dimensions[0]/2, window_dimensions[0]/2)
             y = uniform(-window_dimensions[1]/2, window_dimensions[1]/2)
         rot = uniform(0.0, 360.0)
         velocity_x = uniform(-30, 30)
         velocity_y = uniform(5, 3)
         ent = entities.Asteroid(size, x, y, rot, velocity_x, velocity_y)
         self.game_objects.append(ent)
         return ent
Ejemplo n.º 2
0
 def collides_with(self, other_object):
     collision_distance = self.image.width / 2 * self.scale + other_object.image.width / 2 * self.scale
     actual_distance = distance(self.position, other_object.position)
     return (actual_distance <= collision_distance)