Ejemplo n.º 1
0
    def on_init(self, ev):
        world = PhysicsWorld()
        self.add(world)
 
        pedoA = Sprite("tuqui.png")
        pedoA.top = -100
        pedoA.left = 0
        pedoA.scale(0.5, 0.5)
        pedoA.add(Body(BodyType.static))
        
        pedoB = Sprite("tuqui.png")
        pedoB.top = -300
        pedoB.left = 300
        pedoB.scale(0.5, 0.5)
        pedoB_body = Body()
        pedoB.add(pedoB_body)
        pedoB_body.linear_damping = .02
        
        dj = DistanceJoint(pedoA, pedoB)
        print("created distance Joint")
        
        self.add(pedoA)
        print('added pedoA to scene')
        self.add(pedoB)
        print('added pedoB to scene')
        world.add(dj)
Ejemplo n.º 2
0
 def on_init(self, event):
     print("Init called!")
     s = Sprite("tuqui.png")
     print("Sprite initialized.")
     self.add(s)
     print("Sprite added.")
     s.top = 0
     s.left = 0
     d = s.add(Drag())
Ejemplo n.º 3
0
    def make_sonic(self):
        sonic = Sprite("sonic.png")
        sheet = SpriteSheet("sonic.xml")
        sonic.add(sheet)

        jump_set = sheet.find_by("name", "idle")
        jump_set.loop = True
        jump_set.frame_duration = 15
        jump_set.start()
        sonic.left = 150
        sonic.top = 20
        self.add(sonic)
Ejemplo n.º 4
0
 def on_init(self, e):
     #pydevd.settrace()
     
     world = PhysicsWorld()
     world.pixel_size = 20
     self.add(world)
     
     ground = Sprite("ground.png")
     ground.top = 400
     ground.left = 0
     ground.name = "GROUND";
     self.add(ground)
     ground.add(Body(BodyType.static))
     
     ipod = Sprite("orange.png")
     ipod.top = 300
     ipod.left = 100
     ipod.name = "ORANGE"
     self.ipod_body = Body()
     self.add(ipod)
     ipod.add(self.ipod_body)
     
     target = Sprite("blue.png")
     target.top = 100
     target.left = 0
     target.name = "BLUE"
     self.target_body = Body(BodyType.kinematic)
     self.target = self.add(target)
     target.add(self.target_body)
     
     self.text = Text("Try to hit the blue ipod")
     self.add(self.text)
     self.text.left = 60.0
     self.text.top = 0.0
     self.text.font.color = Color(0x00FFCCFF)
     
     ipod.listen({"pointer_up": self.on_ipod_click})
     
     world.listen({"pre_solve": self.on_collide})
Ejemplo n.º 5
0
    def make_explosion(self):
        explosion = Sprite("explosion.png")
        sheet = SpriteSheet("explosion.xml")
        explosion.add(sheet)
        sheet.loop = True
        self.add(explosion)

        explosion.width = 60
        explosion.height = 60
        explosion.left = 20
        explosion.top = 20

        sheet.start()
        sheet.loop = True
        explosion.sheet = sheet

        return explosion