Ejemplo n.º 1
0
    def __init__(self, mother_ship, melee, body):
        self.body = body
        Actor.__init__(self, melee)
        self.mother_ship = mother_ship

        # Register shapes for collision callbacks
        for s in self.body.shapes:
            melee.contact_register[hash(s)] = self
Ejemplo n.º 2
0
 def __init__(self, surface):
     image_file = 'resources/sprites/bear.png'
     bullet = Bullet('resources/sprites/bullet02.png', surface, 60)
     railgun = Railgun(bullet, 100000, self)
     Actor.__init__(self, image_file=image_file, surface=surface, health=100, damage=5,
                    fire_direction=globals.DIRECTION["TOP"], speed=8, weapon=railgun)
     scaled_size = self._scale(self._size, 2)
     self._image = pygame.transform.scale(self._img, scaled_size)
     self._rect.size = scaled_size
Ejemplo n.º 3
0
 def __init__(self, surface):
     image_file = 'resources/sprites/chungus.jpg'
     bullet = Bullet('resources/sprites/enemy_bullet01.png', surface, 60)
     railgun = Railgun(bullet, 100000, self)
     Actor.__init__(self,
                    image_file=image_file,
                    surface=surface,
                    health=80,
                    damage=1,
                    fire_direction=globals.DIRECTION["BOTTOM"],
                    speed=6,
                    weapon=railgun)
     scaled_size = self._scale(self._size, 6)
     self._image = pygame.transform.scale(self._img, scaled_size)
     self._rect.size = scaled_size
Ejemplo n.º 4
0
 def __init__(self, melee):
     Actor.__init__(self, melee)
     
     # Set max linear and angular velocity
     self.max_linear_velocity = 50
     self.max_angular_velocity = pi
     
     # Physics (based on SVG shapes)
     self.translate = calc_center(self.lines[self.parts.index(self.center_part)])
     self.svg.init(self.translate, self.scale)
     
     bodydef = Body()
     bodydef.ccd = True
     bodydef.position = self.initial_position
     self.body = melee.world.append_body(bodydef)
     self.body.linear_velocity = self.initial_velocity
     self.body.angular_velocity = self.initial_ang_vel
     
     for p in self.lines:
         polygondef = Polygon()
         polygondef.density = self.density
         # Ensure points are oriented ccw
         ccw = convex_hull(p)
         # Translate and scale points
         verts = []
         for v in ccw:
             x = (v[0] - self.translate[0]) * self.scale
             y = (v[1] - self.translate[1]) * self.scale
             verts.append(Vec2(x, y))   
         polygondef.vertices = verts
         polygondef.collision_group = self.group
         shape = self.body.append_shape(polygondef)
         # Register shapes for collision callbacks
         melee.contact_register[hash(shape)] = self
         
     self.body.set_mass_from_shapes()
Ejemplo n.º 5
0
 def __init__(self, melee, body):
     self.body = body
     Actor.__init__(self, melee)