コード例 #1
0
ファイル: kzerZa.py プロジェクト: greenm01/openmelee
 def fire(self):
     
     if not self.primary_time() or self.battery <= self.pEnergy:
         return  
     
     # Drain battery
     self.battery_cost(self.pEnergy)
     
     # Create body and shape
     bodydef = Body()
     bodydef.ccd = True
     bodydef.angle = self.body.angle
     bodydef.position = self.body.get_world_point(Vec2(0, -5))
     shell = self.melee.world.append_body(bodydef)
     angle = vforangle(self.body.angle)
     velocity = rotate(angle, (0.0, -100.0))
     vb = self.body.linear_velocity
     shell.linear_velocity = Vec2(velocity[0]+vb.x, velocity[1]+vb.y)
     
     polydef = Polygon()
     verts = [Vec2(0.5, 0.8), Vec2(-0.5, 0.8), Vec2(-0.5, -0.8), Vec2(0.5, -0.8)]
     polydef.vertices = verts
     polydef.density = 5
     
     shell.append_shape(polydef)
     shell.set_mass_from_shapes()
     
     # Create projectile
     projectile = PrimaryWeapon(self, self.melee, shell)
     projectile.group = self.group
     projectile.lifetime = 2.5
     projectile.damage = 10
     projectile.health = 5
     projectile.shapes = verts 
コード例 #2
0
ファイル: actor.py プロジェクト: greenm01/openmelee
 def debug_draw(self):
     pos = self.body.position
     angle = vforangle(self.body.angle)
     for s in self.body.shapes:
         verts = []
         if isinstance(s, BoundPolygon):
             # Draw polygon
             for v in s.vertices:
                 p = rotate(angle, (v.x, v.y))
                 px = pos.x + p[0]
                 py = pos.y + p[1]
                 verts.append((px, py))
             draw_solid_polygon(verts, self.fill, self.outline)
         else:
             # Draw circle
             v = s.local_position
             p = rotate(angle, (v.x, v.y))
             c1x = pos.x + p[0]
             c1y = pos.y + p[1]
             draw_solid_circle((c1x, c1y), s.radius, self.fill, self.outline) 
     
     # Draw center of mass
     #red = 255, 0, 0
     #draw_circle((pos.x, pos.y), 0.5, red) 
コード例 #3
0
ファイル: ship.py プロジェクト: greenm01/openmelee
 def forward(self):
     a = vforangle(self.body.angle)
     return rotate(self.engine_force, a)