diff options
author | Cristhofer Travieso <cristhofert97@gmail.com> | 2012-10-10 20:10:53 (GMT) |
---|---|---|
committer | Cristhofer Travieso <cristhofert97@gmail.com> | 2012-10-10 20:10:53 (GMT) |
commit | dc1cbc5c0a574a5cbca7543cbdbea5a45dde7232 (patch) | |
tree | 590a0334b9d580858b2ddca0fde30d401103766c | |
parent | 646dbd252787515222ad09943000ce02bdee1e2d (diff) |
Add events
Signed-off-by: Cristhofer Travieso <cristhofert97@gmail.com>
-rwxr-xr-x | game.py | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -9,16 +9,23 @@ class Game(glucosa.GameArea): def __init__(self): glucosa.GameArea.__init__(self) - head = Head() + self.events = glucosa.Events(self) + + head = Head(self.events) self.add_sprite(head) class Head(glucosa.Sprite): - def __init__(self): + def __init__(self, events): image = glucosa.Image('images/head.png') glucosa.Sprite.__init__(self, image, 0, 0) - pass + self.events = events + + self.events.connect('key-press-event', self.key_pressed) + + def key_pressed(self, widget): + print 'ok' if __name__ == '__main__': w = gtk.Window() |