Add blocked check to level
authorNeil <neil@dip.sun.ac.za>
Mon, 15 Apr 2013 12:39:42 +0000 (14:39 +0200)
committerNeil <neil@dip.sun.ac.za>
Mon, 15 Apr 2013 12:39:42 +0000 (14:39 +0200)
erdslangetjie/level.py

index 790557179a7ba5fb6d11361887396fbad8b4896f..4dffd6deb759fa075e29eda28b3867226fef2634 100644 (file)
@@ -44,3 +44,16 @@ class Level(object):
 
     def at_exit(self, pos):
         return pos in self.exit_pos
+
+    def blocked(self, pos):
+        if pos[0] < 0:
+            return True
+        if pos[1] < 0:
+            return True
+        try:
+            tile = self.data[pos[1]][pos[0]]
+        except IndexError:
+            return True
+        if tile == '.':
+            return True
+        return False