about summary refs log tree commit diff homepage
path: root/brutalmaze
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2017-11-21 21:49:35 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2017-11-21 21:49:35 +0700
commit1578586f24c74786976f0c675c901f5e30fa6bbb (patch)
tree5c5b19c2ce1a07af52acaa465bd1618d10d1f92f /brutalmaze
parentfffdd969ad5ab5e4cdde65e0a49940722b1f1282 (diff)
downloadbrutalmaze-1578586f24c74786976f0c675c901f5e30fa6bbb.tar.gz
Update documentation 0.2.0
Diffstat (limited to 'brutalmaze')
-rw-r--r--brutalmaze/characters.py6
-rw-r--r--brutalmaze/constants.py1
-rw-r--r--brutalmaze/maze.py6
3 files changed, 5 insertions, 8 deletions
diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py
index 6daaf70..e123dec 100644
--- a/brutalmaze/characters.py
+++ b/brutalmaze/characters.py
@@ -186,14 +186,12 @@ class Enemy:
         if self.offsety:
             self.offsety -= sign(self.offsety)
             return True
-        if (self.next_strike > pygame.time.get_ticks()
-            or (self.x, self.y) in AROUND_HERO):
-            return False
+        if self.next_strike > pygame.time.get_ticks(): return False
 
         self.move_speed = self.maze.fps / speed
         directions = [(sign(MIDDLE - self.x), 0), (0, sign(MIDDLE - self.y))]
         shuffle(directions)
-        directions.append(choice(CROSS))
+        directions.append(choice((choice(ADJACENT_GRIDS), (0, 0))))
         for x, y in directions:
             if (x or y) and self.maze.map[self.x + x][self.y + y] == EMPTY:
                 self.offsetx = round(x * (1 - self.move_speed))
diff --git a/brutalmaze/constants.py b/brutalmaze/constants.py
index 6cc9103..0ffd6a0 100644
--- a/brutalmaze/constants.py
+++ b/brutalmaze/constants.py
@@ -47,7 +47,6 @@ FIRANGE = 6     # grids
 BULLET_LIFETIME = 1000.0 * FIRANGE / (BULLET_SPEED-HERO_SPEED)  # ms
 EMPTY, WALL, HERO, ENEMY = range(4)
 ADJACENT_GRIDS = (1, 0), (0, 1), (-1, 0), (0, -1)
-CROSS = ADJACENT_GRIDS + ((0, 0),)
 AROUND_HERO = set((MIDDLE + x, MIDDLE + y) for x, y in
                   ADJACENT_GRIDS + ((1, 1), (-1, 1), (-1, -1), (1, -1)))
 
diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py
index 7634e77..ee02d38 100644
--- a/brutalmaze/maze.py
+++ b/brutalmaze/maze.py
@@ -247,7 +247,7 @@ class Maze:
                 fallen.append(i)
         for i in reversed(fallen): self.bullets.pop(i)
 
-    def valid_move(self, vx=0.0, vy=0.0):
+    def is_valid_move(self, vx=0.0, vy=0.0):
         """Return dx or dy if it it valid to move the maze in that
         velocity, otherwise return 0.0.
         """
@@ -270,9 +270,9 @@ class Maze:
         """Update the maze."""
         if self.paused: return
         self.fps = fps
-        dx = self.valid_move(vx=self.vx)
+        dx = self.is_valid_move(vx=self.vx)
         self.centerx += dx
-        dy = self.valid_move(vy=self.vy)
+        dy = self.is_valid_move(vy=self.vy)
         self.centery += dy
 
         if dx or dy: