From acb9e253be9b8d6858682832060c2b3bcf2c416b Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 15 Apr 2013 14:40:05 +0200 Subject: [PATCH] can_move check for player objects --- erdslangetjie/player.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erdslangetjie/player.py b/erdslangetjie/player.py index 6fc26e8..2f8def2 100644 --- 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 -- 2.34.1