2012-01-11 03:53:01 +00:00
|
|
|
import kivy
|
|
|
|
from kivy.app import App
|
|
|
|
from kivy.uix.widget import Widget
|
|
|
|
from kivy.properties import NumericProperty, ReferenceListProperty
|
|
|
|
from kivy.vector import Vector
|
|
|
|
from kivy.factory import Factory
|
|
|
|
|
|
|
|
class PongBall(Widget):
|
|
|
|
velocity_x = NumericProperty(0)
|
|
|
|
velocity_y = NumericProperty(0)
|
|
|
|
velocity = ReferenceListProperty(velocity_x, velocity_y)
|
|
|
|
|
|
|
|
def move(self):
|
|
|
|
self.pos = Vector(*self.velocity) + self.pos
|
|
|
|
|
|
|
|
|
|
|
|
class PongGame(Widget):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class PongApp(App):
|
|
|
|
def build(self):
|
|
|
|
return PongGame()
|
|
|
|
|
|
|
|
|
|
|
|
Factory.register("PongBall", PongBall)
|
2012-07-29 19:43:01 +00:00
|
|
|
if __name__ == '__main__':
|
2012-01-11 03:53:01 +00:00
|
|
|
PongApp().run()
|