From ffe6ba9855433502fc1fde8125a86bc81080ad09 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 1 Jul 2018 21:53:14 +0700 Subject: Chocolate gets you high --- brutalmaze/characters.py | 16 ++++++++++++++++ brutalmaze/game.py | 2 +- brutalmaze/maze.py | 13 +++++++------ setup.py | 2 +- wiki | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/brutalmaze/characters.py b/brutalmaze/characters.py index b6ab9af..e3e6db2 100644 --- a/brutalmaze/characters.py +++ b/brutalmaze/characters.py @@ -44,6 +44,7 @@ class Hero: next_heal (float): minimum wound in ATTACK_SPEED allowing healing again next_beat (float): time until next heart beat (in ms) next_strike (float): time until the hero can do the next attack (in ms) + highness (float): likelihood that the hero shoots toward other angles slashing (bool): flag indicates if the hero is doing close-range attack firing (bool): flag indicates if the hero is doing long-range attack dead (bool): flag indicates if the hero is dead @@ -62,6 +63,7 @@ class Hero: self.next_heal = -1.0 self.next_beat = self.next_strike = 0.0 + self.highness = 0.0 self.slashing = self.firing = self.dead = False self.spin_speed = fps / HERO_HP self.spin_queue = self.wound = 0.0 @@ -119,6 +121,20 @@ class Hero: else: self.spin_queue = delta / unit + def get_shots(self): + """Return list of Bullet shot by the hero.""" + if not self.firing or self.slashing or self.next_strike > 0: return [] + self.next_strike = ATTACK_SPEED + if not randrange(int(self.highness + 1)): + return [Bullet(self.surface, self.x, self.y, + self.angle, 'Aluminium')] + self.highness -= 1.0 + n = self.get_sides() + corners = {randrange(n) for _ in range(n)} + angles = (self.angle + pi*2*corner/n for corner in corners) + return [Bullet(self.surface, self.x, self.y, angle, 'Aluminium') + for angle in angles] + def get_color(self): """Return current color of the hero.""" return self.color[int(self.wound)] diff --git a/brutalmaze/game.py b/brutalmaze/game.py index 95b7c09..5ee547c 100644 --- a/brutalmaze/game.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 . -__version__ = '0.7.7' +__version__ = '0.7.8' import re from argparse import ArgumentParser, FileType, RawTextHelpFormatter diff --git a/brutalmaze/maze.py b/brutalmaze/maze.py index ef1c2fb..6a5f139 100644 --- a/brutalmaze/maze.py +++ b/brutalmaze/maze.py @@ -232,12 +232,17 @@ class Maze: if self.enemy_weights[color] + wound < MAXW: self.enemy_weights[color] += wound if color == 'Orange': + # If called by close-range attack, this is FPS-dependant, although + # in playable FPS (24 to infinity), the difference within 2%. self.hero.next_heal = abs(self.hero.next_heal * (1 - wound)) elif (uniform(0, sum(self.enemy_weights.values())) < self.enemy_weights[color]): self.hero.next_heal = -1.0 # what doesn't kill you heals you if color == 'Butter' or color == 'ScarletRed': wound *= ENEMY_HP + elif color == 'Chocolate': + self.hero.highness += wound + wound = 0 elif color == 'SkyBlue': self.next_move = max(self.next_move, 0) + wound*1000 wound = 0 @@ -266,12 +271,7 @@ class Maze: def track_bullets(self): """Handle the bullets.""" - if (self.hero.firing and not self.hero.slashing - and self.hero.next_strike <= 0): - self.hero.next_strike = ATTACK_SPEED - self.bullets.append(Bullet(self.surface, self.x, self.y, - self.hero.angle, 'Aluminium')) - + self.bullets.extend(self.hero.get_shots()) fallen = [] block = (self.hero.spin_queue and self.hero.next_heal < 0 and self.hero.next_strike > self.hero.spin_queue / self.fps) @@ -447,6 +447,7 @@ class Maze: self.next_move = self.next_slashfx = self.hero.next_strike = 0.0 self.hero.next_heal = -1.0 + self.hero.highness = 0.0 self.hero.slashing = self.hero.firing = self.hero.dead = False self.hero.spin_queue = self.hero.wound = 0.0 self.hero.wounds = deque([0.0]) diff --git a/setup.py b/setup.py index 6151256..7a9807e 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.rst') as f: setup( name='brutalmaze', - version='0.7.7', + version='0.7.8', description='A minimalist TPS game with fast-paced action', long_description=long_description, url='https://github.com/McSinyx/brutalmaze', diff --git a/wiki b/wiki index cdd2e0c..d54cbe6 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit cdd2e0ceaa6a97ae96544a110868fcd70bc2bff7 +Subproject commit d54cbe67d08d2bb3e64e287b68f9635c3fc801dc -- cgit 1.4.1