Пример #1
0
    def __init__(self, engine, w, h, color, shooter, speed, groups=[]):
        self.shooter = shooter
        self.speed = speed

        x = math.cos(math.radians(
            shooter.angle)) * (shooter.rect.width / 2) + shooter.pos.x
        y = math.sin(math.radians(
            shooter.angle)) * (shooter.rect.height / 2) + shooter.pos.y
        Sprite.__init__(self,
                        engine,
                        x,
                        y,
                        w,
                        h,
                        color,
                        groups=groups,
                        auto=False)
        KinematicBody.__init__(self, engine, x, y, w, h)
        self.mass = 1
        self.trigger = True
        self.angle = shooter.angle
        self.rotate()

        self.velocity = Vector2(
            math.cos(math.radians(shooter.angle)) * speed,
            math.sin(math.radians(shooter.angle)) * speed)
Пример #2
0
	def __init__(self,x,y,w,h,surface,physics,material=PhysicMaterial(),groups=[],
			mspeed=1e10,jumpforce=98*2.7,wspeed=80,accel=20,scene=None,
			keys={"LEFT":K_LEFT,"RIGHT":K_RIGHT,"UP":K_UP,"DOWN":K_DOWN}):
	
		Sprite.__init__(self,x,y,w,h,surface,groups=groups)
		RigidBodyController.__init__(self,x,y,w,h,physics,keys,
			material=material,scene=scene,
			mspeed=mspeed,jumpforce=jumpforce,wspeed=wspeed,accel=accel)
Пример #3
0
    def __init__(self,
                 engine,
                 x,
                 y,
                 w,
                 h,
                 color,
                 groups=[],
                 r=-90,
                 accel=25,
                 mspeed=100,
                 rotatespeed=300,
                 weapon=None,
                 keys={
                     "LEFT": K_LEFT,
                     "RIGHT": K_RIGHT,
                     "UP": K_UP,
                     "DOWN": K_DOWN
                 }):

        Sprite.__init__(self,
                        engine,
                        x,
                        y,
                        w,
                        h,
                        ALPHA,
                        groups=groups,
                        auto=False)
        RigidBodyController.__init__(self,
                                     engine,
                                     x,
                                     y,
                                     w,
                                     h,
                                     keys,
                                     speed=mspeed,
                                     accel=accel)

        self.angle = r
        self.velocity.y = -100
        self.slowdown = 0

        self.shooting = False
        self.weapon = None
        self.rotatespeed = rotatespeed
        self.shipcolor = color

        self.points = [(0, 0), (0, h), (w, h / 2)]
        pygame.draw.polygon(self.origin_image, color, self.points)
Пример #4
0
 def __init__(self,
              engine,
              x,
              y,
              w,
              h,
              color,
              material=PhysicMaterial(),
              groups=[]):
     Sprite.__init__(self,
                     engine,
                     x,
                     y,
                     w,
                     h,
                     color,
                     groups=groups,
                     auto=False)
     RectCollider.__init__(self, engine, x, y, w, h, material=material)
Пример #5
0
    def __init__(self,
                 engine,
                 x,
                 y,
                 r,
                 color,
                 material=PhysicMaterial(),
                 groups=[]):
        Sprite.__init__(self,
                        engine,
                        x,
                        y,
                        r,
                        r,
                        color,
                        groups=groups,
                        auto=False)
        RigidBody.__init__(self, engine, x, y, r, r, 1e5, material=material)

        self.velocity.x = random.randint(-200, 200)
        self.velocity.y = random.randint(-200, 200)

        self.rot_speed = random.random() * 5
Пример #6
0
	def __init__(self,x,y,w,h,color,physics,groups=[],scene=None,
			keys={"LEFT":K_LEFT,"RIGHT":K_RIGHT,"UP":K_UP,"DOWN":K_DOWN}):
		
		Sprite.__init__(self,x,y,w,h,color,groups=groups)
		KinematicController.__init__(self,x,y,w,h,physics,keys,scene=scene)
Пример #7
0
	def __init__(self,x,y,w,h,color,material=PhysicMaterial(),groups=[],scene=None):
		Sprite.__init__(self,x,y,w,h,color,groups=groups)
		Collider.__init__(self,x,y,w,h,material=material,scene=scene)
Пример #8
0
 def __init__(self, engine, surface):
     Sprite.__init__(self, engine, 0, 0, 1, 1, surface, rotate=False)
     self.randomize()
     self.make_velocity()