Exemple #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)
    def on_init(self, ev):
        self.world = PhysicsWorld()
        self.add(self.world)
 
        self.ground = Sprite("ground.png")
        self.ground.top = 500
        self.ground.left = 20
        self.ground.scale(1.5, 0.5)
        self.ground.add(Body(BodyType.static))
        
        self.tuqui = Sprite("tuqui.png")
        self.tuqui.top = -300
        self.tuqui.left = 300
        self.tuqui.scale(0.5, 0.5)
        self.tuqui_body = Body()
        self.tuqui.add(self.tuqui_body)
        
        self.add(self.ground)
        print('added ground to scene')
        self.add(self.tuqui)
        print('added tuqui to scene')
    
        self.dragging = False
        
        self.tuqui.listen({"pointer_up": self.on_tuqui_up})
        self.tuqui.listen({"pointer_down": self.on_tuqui_down})
Exemple #3
0
    def on_init(self, ev):
        
        world = PhysicsWorld()
        self.add(world)

        self.import_from("bowling.xml")
        
        self.pin = self.find_by_class(Pin)
class PhysicsJointScene(Scene):
    def on_init(self, ev):
        self.world = PhysicsWorld()
        self.add(self.world)
 
        self.ground = Sprite("ground.png")
        self.ground.top = 500
        self.ground.left = 20
        self.ground.scale(1.5, 0.5)
        self.ground.add(Body(BodyType.static))
        
        self.tuqui = Sprite("tuqui.png")
        self.tuqui.top = -300
        self.tuqui.left = 300
        self.tuqui.scale(0.5, 0.5)
        self.tuqui_body = Body()
        self.tuqui.add(self.tuqui_body)
        
        self.add(self.ground)
        print('added ground to scene')
        self.add(self.tuqui)
        print('added tuqui to scene')
    
        self.dragging = False
        
        self.tuqui.listen({"pointer_up": self.on_tuqui_up})
        self.tuqui.listen({"pointer_down": self.on_tuqui_down})
        
    def on_tuqui_up(self, e):
        self.world.remove(self.mj)
        self.dragging = False
        print("up")
    
    def on_tuqui_down(self, e):
        # construct this bitch and add to the world
        self.mj = MouseJoint(self.ground, self.tuqui)
        self.world.add(self.mj)
        self.dragging = True
        print("down")
        
    def on_render(self, e):
        if not self.dragging:
            return
        
        self.mj.update(self.scene.pointer)
    def on_init(self, ev):
        self.sprite = Sprite("tuqui.png")
        self.world = PhysicsWorld()

        self.add(self.world)
        self.add(self.sprite)

        self.sprite_body = Body(BodyType.kinematic)
        self.sprite.add(self.sprite_body)

        self.body_drag = BodyDrag(self.sprite_body)
        self.sprite.add(self.body_drag)
Exemple #6
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})
Exemple #7
0
    def on_init(self, ev):
        self.world = PhysicsWorld()
        self.add(self.world)

        self.tuqui = Sprite("tuqui.png")
        self.tuqui.top = 0
        self.tuqui.left = 300
        self.tuqui.scale(0.5, 0.5)
        self.tuqui_body = Body()
        self.tuqui_body.type = BodyType.kinematic

        self.tuqui.add(self.tuqui_body)
        self.add(self.tuqui)
        bd = BodyDrag(self.tuqui_body)
        bd.always_drag = False
        self.tuqui.add(bd)
        print('added tuqui to scene')