Esempio n. 1
0
 def on_touch_down(self, touch):
     touchedCircle = touchingCircle(self.bodies, touch)
     if touchedCircle:
         touch.ud['circle'] = touchedCircle
         touch.ud['mass'] = touchedCircle.m_mass
         touch.ud['tail'] = list()
         touchedCircle.m_mass = 0
         touchedCircle.m_velocity = Vector2()
     else:
         mass = int(random() * 10) + 10
         circle = Circle( mass, Vector2(touch.x, touch.y), mass, Vector2(0,-550) )
         color = (random(), random(), random())
         circle.setColor( color )
         self.bodies.append(circle)
Esempio n. 2
0
    def __init__(self):
        self.bodies = list()
        self.joints = list()
        self.time = 0
        Clock.schedule_interval(self.main_loop, 1 / 60.)
        self.bodies.append(Plane(Vector2(-1, 0), xDistance))
        self.bodies.append(Plane(Vector2(0, -1), yDistance))
        self.bodies.append(Plane(Vector2(1, 0), 0))
        self.bodies.append(Plane(Vector2(0, 1), 0))
        Window.bind(on_motion=self.on_motion)

        for ii in range(0, 4):
            mass = 20
            if ii == 0:
                circle = Circle(
                    mass, Vector2(Window.width / 2.0, Window.height - 20), 0)
                circle.setColor(color=(random(), random(), random()))
                self.bodies.append(circle)
            else:
                circle = Circle(mass, Vector2.randomRadius(20), mass)
                circle.setColor(color=(random(), random(), random()))
                self.bodies.append(circle)

        for jj in range(4, 7):
            self.joints.append(
                DistanceConstraint(self.bodies[jj], self.bodies[jj + 1], 60))

        super(BounceBallWidget, self).__init__()
Esempio n. 3
0
 def on_touch_down(self, touch):
     touchedCircle = touchingCircle(self.bodies, touch)
     if touchedCircle:
         touch.ud['circle'] = touchedCircle
         touch.ud['mass'] = touchedCircle.m_mass
         touch.ud['tail'] = list()
         touchedCircle.m_mass = 0
         touchedCircle.m_velocity = Vector2()
     else:
         mass = int(random() * 10) + 10
         circle = Circle(mass, Vector2(touch.x, touch.y), mass,
                         Vector2(0, -550))
         color = (random(), random(), random())
         circle.setColor(color)
         self.bodies.append(circle)
Esempio n. 4
0
 def __init__(self):
     self.bodies = list()
     self.joints = list()
     self.time = 0
     Clock.schedule_interval(self.main_loop, 1 / 60.)
     self.bodies.append( Plane( Vector2(-1, 0), xDistance ) )
     self.bodies.append( Plane( Vector2(0, -1), yDistance ) )
     self.bodies.append( Plane( Vector2(1, 0), 0 ) )
     self.bodies.append( Plane( Vector2(0, 1), 0 ) )
     Window.bind(on_motion=self.on_motion)
     
     for ii in range(0, 4):
         mass = 20
         if ii == 0:
             circle = Circle(mass, Vector2(Window.width / 2.0, Window.height - 20), 0)
             circle.setColor(color = (random(), random(), random()))
             self.bodies.append(circle)
         else:
             circle = Circle(mass, Vector2.randomRadius(20), mass)
             circle.setColor(color = (random(), random(), random()))
             self.bodies.append( circle )
             
     for jj in range(4, 7):
         self.joints.append( DistanceConstraint( self.bodies[jj], self.bodies[jj + 1], 60) )
             
     super(BounceBallWidget, self).__init__()