From 519fd95e4107ab9cc9a8076e3180624195d9b5cb Mon Sep 17 00:00:00 2001 From: olpc user Date: Mon, 05 Nov 2012 19:30:07 +0000 Subject: More nice rotation Signed-off-by: olpc user --- 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() diff --git a/icons/eat.png b/icons/eat.png new file mode 100644 index 0000000..9086f55 --- /dev/null +++ b/icons/eat.png Binary files differ diff --git a/icons/eat.svg b/icons/eat.svg new file mode 100644 index 0000000..05a24fd --- /dev/null +++ b/icons/eat.svg @@ -0,0 +1,65 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + -- cgit v0.9.1