summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-07-01 21:53:14 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-07-02 11:04:46 +0700
commitffe6ba9855433502fc1fde8125a86bc81080ad09 (patch)
tree45a63181d20bb04c35ce86810b169e4ceb45800d
parentfc05e0ccee392985d67872507bc5476a5775142c (diff)
downloadbrutalmaze-ffe6ba9855433502fc1fde8125a86bc81080ad09.tar.gz
Chocolate gets you high
-rw-r--r--brutalmaze/characters.py16
-rw-r--r--brutalmaze/game.py2
-rw-r--r--brutalmaze/maze.py13
-rwxr-xr-xsetup.py2
m---------wiki0
5 files changed, 25 insertions, 8 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 <https://www.gnu.org/licenses/>.
 
-__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
-Subproject cdd2e0ceaa6a97ae96544a110868fcd70bc2bff
+Subproject d54cbe67d08d2bb3e64e287b68f9635c3fc801d