Mercurial > touhou
comparison pytouhou/game/enemy.py @ 143:ea21bb37febe
Add max bullets limit
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 25 Sep 2011 21:00:43 +0200 |
parents | c53d91300c1c |
children | 5cf927cbd9c5 |
comparison
equal
deleted
inserted
replaced
142:c7f0fd9d2145 | 143:ea21bb37febe |
---|---|
106 launch_angle += pi / bullets_per_shot | 106 launch_angle += pi / bullets_per_shot |
107 if type_ != 75: | 107 if type_ != 75: |
108 launch_angle -= angle * (bullets_per_shot - 1) / 2. | 108 launch_angle -= angle * (bullets_per_shot - 1) / 2. |
109 | 109 |
110 bullets = self._game_state.bullets | 110 bullets = self._game_state.bullets |
111 nb_bullets_max = self._game_state.nb_bullets_max | |
111 | 112 |
112 for shot_nb in range(number_of_shots): | 113 for shot_nb in range(number_of_shots): |
113 shot_speed = speed if shot_nb == 0 else speed + (speed2 - speed) * float(shot_nb) / float(number_of_shots) | 114 shot_speed = speed if shot_nb == 0 else speed + (speed2 - speed) * float(shot_nb) / float(number_of_shots) |
114 bullet_angle = launch_angle | 115 bullet_angle = launch_angle |
115 for bullet_nb in range(bullets_per_shot): | 116 for bullet_nb in range(bullets_per_shot): |
117 if nb_bullets_max is not None and len(bullets) == nb_bullets_max: | |
118 break | |
119 | |
116 if type_ == 75: # 102h.exe@0x4138cf | 120 if type_ == 75: # 102h.exe@0x4138cf |
117 bullet_angle = self._game_state.prng.rand_double() * (launch_angle - angle) + angle | 121 bullet_angle = self._game_state.prng.rand_double() * (launch_angle - angle) + angle |
118 if type_ in (74, 75): # 102h.exe@0x4138cf | 122 if type_ in (74, 75): # 102h.exe@0x4138cf |
119 shot_speed = self._game_state.prng.rand_double() * (speed - speed2) + speed2 | 123 shot_speed = self._game_state.prng.rand_double() * (speed - speed2) + speed2 |
120 bullets.append(Bullet(launch_pos, bullet_type, sprite_idx_offset, | 124 bullets.append(Bullet(launch_pos, bullet_type, sprite_idx_offset, |