Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/game.py
diff options
context:
space:
mode:
Diffstat (limited to 'game.py')
-rwxr-xr-xgame.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/game.py b/game.py
index f008667..428525a 100755
--- a/game.py
+++ b/game.py
@@ -27,7 +27,13 @@ class Head(glucosa.Sprite):
def _key_pressed(self, _event):
if _event.is_pressed(_event.K_UP):
- self._to_rotate = 0
+ if self.rotate == 270:
+ self._to_rotate = 360
+ elif self.rotate == 90:
+ self._to_rotate = 0
+ elif self.rotate == 180:
+ self._to_rotate = 0
+
elif _event.is_pressed(_event.K_DOWN):
self._to_rotate = 180
elif _event.is_pressed(_event.K_RIGHT):
@@ -62,9 +68,27 @@ class Head(glucosa.Sprite):
elif self.rotation == 270:
self.x -= 2
+ x, y, w, h = widget.get_allocation()
+
+ if self.x < 0:
+ self.x = 0
+ elif self.x > w:
+ self.x = w
+ elif self.y < 0:
+ self.y = 0
+ elif self.y > h:
+ self.y = h
+
+class Eat(glucosa.Sprite):
+
+ def __init__(self):
+ _image = glucosa.Image('images/eat.png')
+ glucosa.Sprite.__init__(self, _image, 0, 0)
+
if __name__ == '__main__':
w = gtk.Window()
w.maximize()
+ w.connect('destroy', gtk.main_quit)
w.add(Game())
w.show_all()
gtk.main()