comparison pytouhou/game/bullet.pyx @ 550:f1be00de4b3f

Use the correct division factor for player bullets’ cancellation.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 26 May 2014 00:20:26 +0200
parents e35bef07290d
children 3c2f96f1d715
comparison
equal deleted inserted replaced
549:56bca8ce4b68 550:f1be00de4b3f
9 ## This program is distributed in the hope that it will be useful, 9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details. 12 ## GNU General Public License for more details.
13 ## 13 ##
14
15 cimport cython
14 16
15 from libc.math cimport cos, sin, atan2, M_PI as pi 17 from libc.math cimport cos, sin, atan2, M_PI as pi
16 18
17 from pytouhou.vm import ANMRunner 19 from pytouhou.vm import ANMRunner
18 from pytouhou.game.sprite cimport Sprite 20 from pytouhou.game.sprite cimport Sprite
122 cdef void collide(self): 124 cdef void collide(self):
123 self.cancel() 125 self.cancel()
124 self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size. 126 self._game.new_particle((self.x, self.y), 10, 256) #TODO: find the real size.
125 127
126 128
129 @cython.cdivision(True)
127 cdef void cancel(self): 130 cdef void cancel(self):
128 # Cancel animation 131 # Cancel animation
129 bt = self._bullet_type 132 bt = self._bullet_type
130 self.sprite = Sprite() 133 self.sprite = Sprite()
131 if self.player >= 0: 134 if self.player >= 0:
132 self.sprite.angle = self.angle - pi 135 self.sprite.angle = self.angle - pi
136 divisor = 8.
133 else: 137 else:
134 self.sprite.angle = self.angle 138 self.sprite.angle = self.angle
139 divisor = 2.
135 self.anmrunner = ANMRunner(bt.anm, bt.cancel_anim_index, 140 self.anmrunner = ANMRunner(bt.anm, bt.cancel_anim_index,
136 self.sprite, bt.launch_anim_offsets[self.sprite_idx_offset]) 141 self.sprite, bt.launch_anim_offsets[self.sprite_idx_offset])
137 self.dx, self.dy = self.dx / 2., self.dy / 2. 142 self.dx /= divisor
143 self.dy /= divisor
138 144
139 self.state = CANCELLED 145 self.state = CANCELLED
140 146
141 147
142 cdef void update(self): 148 cdef void update(self):