changeset 184:54eb6b254b7b

When touched, drop the items at the right place, and add precisions about particles.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 26 Oct 2011 02:38:50 -0700
parents b6d7ce644f34
children 68e6d3faeee6
files pytouhou/game/enemy.py pytouhou/game/game.py pytouhou/game/player.py
diffstat 3 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -169,6 +169,7 @@ class Enemy(object):
     def on_attack(self, bullet):
         if self.damageable:
             self.life -= bullet._bullet_type.damage
+            self._game.new_particle((self.x, self.y), 1, 3., 192) #TODO: find the real size and range.
 
 
     def on_collide(self):
@@ -180,7 +181,7 @@ class Enemy(object):
         #TODO: 8 white particles are used only in stage 3 to 6,
         # in other stages they are 2 red and 6 blue.
         for i in range(8):
-            self._game.new_particle((self.x, self.y), 0, 3., 192)
+            self._game.new_particle((self.x, self.y), 0, 3., 192) #TODO: find the real size and range.
 
 
     def set_pos(self, x, y, z):
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -163,8 +163,9 @@ class Game(object):
                 elif not bullet.grazed and not (bx2 < gx1 or bx1 > gx2
                         or by2 < gy1 or by1 > gy2):
                     bullet.grazed = True
+                    player.state.graze += 1
                     player.state.score += 500 # found experimentally
-                    self.new_particle((px, py), 0, .8, 192)
+                    self.new_particle((px, py), 0, .8, 192) #TODO: find the real size and range.
                     #TODO: display a static particle during one frame at
                     # 12 pixels of the player, in the axis of the “collision”.
 
--- a/pytouhou/game/player.py
+++ b/pytouhou/game/player.py
@@ -127,12 +127,22 @@ class Player(object):
             time = self._game.frame - self.death_time
             if time == 6: # too late, you are dead :(
                 self.state.touchable = False
-                self._game.drop_bonus(self.state.x, self.state.y, 2, end_pos=None) #TODO: find the formula
+                self.state.lives -= 1
+                if self.state.power > 16:
+                    self.state.power -= 16
+                else:
+                    self.state.power = 0
+
+                self._game.drop_bonus(self.state.x, self.state.y, 2,
+                                      end_pos=(self._game.prng.rand_double() * 288 + 48, # 102h.exe@0x41f3dc
+                                               self._game.prng.rand_double() * 192 - 64))        # @0x41f3
                 for i in range(5):
-                    self._game.drop_bonus(self.state.x, self.state.y, 0, end_pos=None) #TODO: find the formula
-                self.state.lives -= 1
+                    self._game.drop_bonus(self.state.x, self.state.y, 0,
+                                          end_pos=(self._game.prng.rand_double() * 288 + 48,
+                                                   self._game.prng.rand_double() * 192 - 64))
+
                 for i in range(16):
-                    self._game.new_particle((self.state.x, self.state.y), 0, 4., 256)
+                    self._game.new_particle((self.state.x, self.state.y), 0, 4., 256) #TODO: find the real size and range.
 
             elif time == 7:
                 self._sprite.mirrored = False