projects
/
erdslangetjie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
49aebbc
)
can_move check for player objects
author
Neil
<neil@dip.sun.ac.za>
Mon, 15 Apr 2013 12:40:05 +0000
(14:40 +0200)
committer
Neil
<neil@dip.sun.ac.za>
Mon, 15 Apr 2013 12:40:05 +0000
(14:40 +0200)
erdslangetjie/player.py
patch
|
blob
|
history
diff --git
a/erdslangetjie/player.py
b/erdslangetjie/player.py
index 6fc26e887dcd2a4e057293e3dbe204b49024acd3..2f8def2976ae4bf0c7e1dabb6d295c2702108996 100644
(file)
--- a/
erdslangetjie/player.py
+++ b/
erdslangetjie/player.py
@@
-12,6
+12,11
@@
class PlayerSprite(object):
def move(self, direction):
self.pos = (self.pos[0] + direction[0], self.pos[1] + direction[1])
+ def can_move(self, direction, level):
+ '''Check if we can move in the given direction'''
+ cand_pos = (self.pos[0] + direction[0], self.pos[1] + direction[1])
+ return not level.blocked(cand_pos)
+
def get_image(self):
return self.sprite