kivy/examples/tutorials/pong/steps/step3/main.py

29 lines
631 B
Python
Raw Normal View History

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)
if __name__ == '__main__':
2012-01-11 03:53:01 +00:00
PongApp().run()