about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-02-28 22:06:03 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-02-28 22:06:03 +0700
commit79ae3ed383e3a13701227912feae83535ddd1c7a (patch)
treea9278160cd28677b48399b415a5c1548814d943c
parent781b347fcb96b72c46bbbe2878d499a19926fd18 (diff)
downloadbrutalmaze-79ae3ed383e3a13701227912feae83535ddd1c7a.tar.gz
Specify imports, fix frozen bullets on game-over and uniform object value export
-rw-r--r--brutalmaze/characters.py12
-rw-r--r--brutalmaze/game.py (renamed from brutalmaze/main.py)9
-rw-r--r--brutalmaze/maze.py9
-rw-r--r--brutalmaze/weapons.py3
-rwxr-xr-xsetup.py4
5 files changed, 23 insertions, 14 deletions
diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py
index 9a53a8f..53048bd 100644
--- a/brutalmaze/characters.py
+++ b/brutalmaze/characters.py
@@ -23,10 +23,12 @@ from math import atan, atan2, sin, pi
 from random import choice, randrange, shuffle
 from sys import modules
 
-import pygame
 from pygame.time import get_ticks
 
-from .constants import *
+from .constants import (
+    TANGO, HERO_HP, SFX_HEART, HEAL_SPEED, MIN_BEAT, ATTACK_SPEED, ENEMY,
+    ENEMY_SPEED, ENEMY_HP, SFX_SLASH_HERO, MIDDLE, WALL, FIRANGE, AROUND_HERO,
+    ADJACENT_GRIDS, EMPTY, FG_COLOR, SQRT2, MINW)
 from .misc import sign, cosin, randsign, regpoly, fill_aapolygon, choices, play
 from .weapons import Bullet
 
@@ -93,11 +95,15 @@ class Hero:
             self.spin_queue = 0.0
             self.angle = angle
 
+    def get_color(self):
+        """Return current color of the hero."""
+        return self.color[int(self.wound)]
+
     def draw(self):
         """Draw the hero."""
         sides = 3 if get_ticks() >= self.next_heal else 4
         trigon = regpoly(sides, self.R, self.angle, self.x, self.y)
-        fill_aapolygon(self.surface, trigon, self.color[int(self.wound)])
+        fill_aapolygon(self.surface, trigon, self.get_color())
 
     def resize(self, maze_size):
         """Resize the hero."""
diff --git a/brutalmaze/main.py b/brutalmaze/game.py
index 1da8056..d6e46e8 100644
--- a/brutalmaze/main.py
+++ b/brutalmaze/game.py
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with Brutal Maze.  If not, see <https://www.gnu.org/licenses/>.
 
-__version__ = '0.5.4'
+__version__ = '0.5.5'
 
 import re
 from argparse import ArgumentParser, FileType, RawTextHelpFormatter
@@ -26,7 +26,6 @@ try:                    # Python 3
     from configparser import ConfigParser
 except ImportError:     # Python 2
     from ConfigParser import ConfigParser
-from itertools import repeat
 from math import atan2, degrees, radians
 from os.path import join, pathsep
 from socket import socket, SOL_SOCKET, SO_REUSEADDR
@@ -174,9 +173,9 @@ class Game:
         if walls: lines.appendleft('\n'.join(''.join(str(cell) for cell in row)
                                              for row in walls))
         x, y = self.expos(maze.x, maze.y)
-        lines.appendleft('{} {} {} {} {} {} {:.0f} {:d} {:d}'.format(
-            len(walls), ne, nb, maze.get_score(), x, y, hero.wound,
-            hero.next_strike <= tick, hero.next_heal <= tick))
+        lines.appendleft('{} {} {} {} {} {} {} {:d} {:d}'.format(
+            len(walls), ne, nb, maze.get_score(), COLORS[hero.get_color()],
+            x, y, hero.next_strike <= tick, hero.next_heal <= tick))
         return '\n'.join(lines).encode()
 
     def update(self):
diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py
index ee3f82d..e49c30d 100644
--- a/brutalmaze/maze.py
+++ b/brutalmaze/maze.py
@@ -24,11 +24,14 @@ from math import pi, log
 from random import choice, getrandbits, uniform
 
 import pygame
-from pygame import RESIZABLE
 from pygame.time import get_ticks
 
 from .characters import Hero, new_enemy
-from .constants import *
+from .constants import (
+    EMPTY, WALL, HERO, ROAD_WIDTH, MAZE_SIZE, MIDDLE, INIT_SCORE, ENEMIES,
+    MINW, MAXW, SQRT2, SFX_SPAWN, SFX_SLASH_ENEMY, SFX_LOSE, ADJACENT_GRIDS,
+    BG_COLOR, FG_COLOR, CELL_WIDTH, LAST_ROW, HERO_HP, ENEMY_HP, ATTACK_SPEED,
+    HERO_SPEED, BULLET_LIFETIME)
 from .misc import round2, sign, regpoly, fill_aapolygon, play
 from .weapons import Bullet
 
@@ -323,7 +326,7 @@ class Maze:
         if not self.hero.dead:
             self.hero.update(fps)
             self.slash()
-            self.track_bullets()
+        self.track_bullets()
 
     def resize(self, size):
         """Resize the maze."""
diff --git a/brutalmaze/weapons.py b/brutalmaze/weapons.py
index 67e513d..f99d694 100644
--- a/brutalmaze/weapons.py
+++ b/brutalmaze/weapons.py
@@ -23,7 +23,8 @@ from math import cos, sin
 
 from pygame.time import get_ticks
 
-from .constants import *
+from .constants import (BULLET_LIFETIME, SFX_SHOT_ENEMY, SFX_SHOT_HERO,
+                        SFX_MISSED, BULLET_SPEED, ENEMY_HP, TANGO, BG_COLOR)
 from .misc import regpoly, fill_aapolygon
 
 
diff --git a/setup.py b/setup.py
index 8fe5d9f..9b3e3da 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('README.rst') as f:
 
 setup(
     name='brutalmaze',
-    version='0.5.4',
+    version='0.5.5',
     description='A minimalist hack and slash game with fast-paced action',
     long_description=long_description,
     url='https://github.com/McSinyx/brutalmaze',
@@ -29,4 +29,4 @@ setup(
     packages=['brutalmaze'],
     install_requires=['appdirs', 'pygame>=1.9'],
     package_data={'brutalmaze': ['icon.png', 'soundfx/*.ogg', 'settings.ini']},
-    entry_points={'gui_scripts': ['brutalmaze = brutalmaze:main']})
+    entry_points={'gui_scripts': ['brutalmaze = brutalmaze.game:main']})