From 4370b1531d7bd5f84340254014e4d9479609239d Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Fri, 24 Nov 2017 20:43:47 +0700 Subject: Make critical close-range hits independent of FPS --- brutalmaze/characters.py | 8 +++----- brutalmaze/constants.py | 2 +- brutalmaze/maze.py | 4 ++-- setup.py | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py index e123dec..0947300 100644 --- a/brutalmaze/characters.py +++ b/brutalmaze/characters.py @@ -63,10 +63,11 @@ class Hero: def update(self, fps): """Update the hero.""" + if self.dead: return old_speed, time = self.spin_speed, pygame.time.get_ticks() self.spin_speed = fps / (HERO_HP-self.wound**0.5) self.spin_queue *= self.spin_speed / old_speed - if not self.dead and time > self.next_heal: + if time > self.next_heal: self.wound -= HEAL_SPEED / self.spin_speed / HERO_HP if self.wound < 0: self.wound = 0.0 @@ -82,10 +83,7 @@ class Hero: self.angle = atan2(y - self.y, x - self.x) self.spin_queue = 0.0 trigon = regpoly(3, self.R, self.angle, self.x, self.y) - try: - fill_aapolygon(self.surface, trigon, self.color[int(self.wound)]) - except IndexError: # When the hero is wounded over his HP - self.wound = HERO_HP + fill_aapolygon(self.surface, trigon, self.color[int(self.wound)]) def die(self): """Handle the hero's death.""" diff --git a/brutalmaze/constants.py b/brutalmaze/constants.py index 0ffd6a0..5f5e25a 100644 --- a/brutalmaze/constants.py +++ b/brutalmaze/constants.py @@ -63,6 +63,6 @@ ENEMIES = ['Butter', 'Orange', 'Chocolate', 'Chameleon', 'SkyBlue', 'Plum', 'ScarletRed'] MINW, MAXW = 24, 36 ENEMY_HP = 3 -HERO_HP = 6 +HERO_HP = 5 BG_COLOR = TANGO['Aluminium'][-1] FG_COLOR = TANGO['Aluminium'][0] diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py index ee02d38..db7672c 100644 --- a/brutalmaze/maze.py +++ b/brutalmaze/maze.py @@ -186,7 +186,7 @@ class Maze: < self.enemy_weights[color]) time = pygame.time.get_ticks() if (color == 'Butter' or color == 'ScarletRed') and fx: - self.hero.wound += 1.0 + self.hero.wound += wound * 2.5 elif color == 'Orange' and fx: self.hero.next_heal = max(self.hero.next_heal, time) + wound*1000 elif color == 'SkyBlue' and fx: @@ -195,6 +195,7 @@ class Maze: self.hero.wound += wound if self.enemy_weights[color] + wound < MAXW: self.enemy_weights[color] += wound + if self.hero.wound > HERO_HP: self.lose() def slash(self): """Handle close-range attacks.""" @@ -288,7 +289,6 @@ class Maze: pygame.display.flip() pygame.display.set_caption('Brutal Maze - Score: {}'.format( int(self.score - INIT_SCORE))) - if self.hero.wound + 1 > HERO_HP: self.lose() def move(self, x, y, fps): """Command the hero to move faster in the given direction.""" diff --git a/setup.py b/setup.py index 67f43eb..1eea8e4 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.rst') as f: setup( name='brutalmaze', - version='0.2.0', + version='0.2.1', description='A hash and slash game with fast-paced action and a minimalist art style', long_description=long_description, url='https://github.com/McSinyx/brutalmaze', -- cgit 1.4.1