mirror of https://github.com/kivy/kivy.git
29 lines
631 B
Python
29 lines
631 B
Python
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__':
|
|
PongApp().run()
|