Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristhofer Travieso <cristhofert97@gmail.com>2012-10-11 23:35:20 (GMT)
committer Cristhofer Travieso <cristhofert97@gmail.com>2012-10-11 23:35:20 (GMT)
commitcee946023a5887cd6a090702478fe1d5d40fe39e (patch)
tree3832b4bd73d839c5d510f78f4ce69142c910ff72
parent9645a9fc56d9c6aac59b00fd88326cf6e7631f3d (diff)
add to move always
Signed-off-by: Cristhofer Travieso <cristhofert97@gmail.com>
-rwxr-xr-xgame.py17
-rw-r--r--images/head.pngbin3430 -> 3564 bytes
2 files changed, 14 insertions, 3 deletions
diff --git a/game.py b/game.py
index eb864ee..67fd588 100755
--- a/game.py
+++ b/game.py
@@ -11,6 +11,7 @@ class Game(glucosa.GameArea):
_events = glucosa.Events(self)
_head = Head(_events)
+ self.connect('draw', _head._update)
self.add_sprite(_head)
@@ -18,10 +19,10 @@ class Game(glucosa.GameArea):
class Head(glucosa.Sprite):
def __init__(self, _events):
_image = glucosa.Image('images/head.png')
- glucosa.Sprite.__init__(self, _image, 100, 100)
- _events.connect('key-pressed', self.key_pressed)
+ glucosa.Sprite.__init__(self, _image, 600, 400)
+ _events.connect('key-pressed', self._key_pressed)
- def key_pressed(self, _event):
+ def _key_pressed(self, _event):
if _event.is_pressed(_event.K_UP):
self.set_rotation(0)
elif _event.is_pressed(_event.K_DOWN):
@@ -31,6 +32,16 @@ class Head(glucosa.Sprite):
elif _event.is_pressed(_event.K_LEFT):
self.set_rotation(270)
+ def _update(self, widget, event):
+ if self.rotation == 0:
+ self.y -= 2
+ elif self.rotation == 90:
+ self.x += 2
+ elif self.rotation == 180:
+ self.y += 2
+ elif self.rotation == 270:
+ self.x -= 2
+
if __name__ == '__main__':
w = gtk.Window()
w.maximize()
diff --git a/images/head.png b/images/head.png
index cce1d50..68aa7c7 100644
--- a/images/head.png
+++ b/images/head.png
Binary files differ