Created
September 17, 2012 20:10
-
-
Save tshirtman/3739495 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from kivy.app import App | |
| from kivy.uix.widget import Widget | |
| #from kivy.graphics import Color, Ellipse | |
| from kivy.graphics import Rectangle | |
| from kivy.lang import Builder | |
| from kivy.animation import Animation | |
| from kivy.core.image import Image | |
| from kivy.properties import ObjectProperty | |
| Builder.load_string(''' | |
| #:kivy 1.4.0 | |
| <AreaLevel>: | |
| canvas.before: | |
| PushMatrix | |
| Translate: | |
| xy: root.pos | |
| canvas: | |
| Rectangle: | |
| texture: root.barrel_image.texture if root.barrel_image else None | |
| pos: 0, 0 | |
| size: 128, 64 | |
| canvas.after: | |
| PopMatrix | |
| ''') | |
| class AreaLevel(Widget): | |
| barrel_image = ObjectProperty(None) | |
| def __init__(self, **kw): | |
| super(AreaLevel, self).__init__(**kw) | |
| self.barrel_image = Image('barrel.png') #, mipmap=True) | |
| for i in range(20): | |
| for j in range(20): | |
| with self.canvas: | |
| Rectangle(texture=self.barrel_image.texture, pos=(30 * i, 30 * j), size=(128, 64)) | |
| def on_touch_down(self, touch): | |
| anim = Animation(x=(self.x + 100) % 500 , y=100) | |
| anim.start(self) | |
| class Building(Widget): | |
| pass | |
| class GameApp(App): | |
| def build(self): | |
| return AreaLevel() | |
| if __name__ == '__main__': | |
| GameApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking good!