# HG changeset patch # User Thibaut Girka # Date 1316977243 -7200 # Node ID ea21bb37febeb30a4440e590766740da67125d83 # Parent c7f0fd9d2145d4999489ec7cdb1304293a97d742 Add max bullets limit diff --git a/pytouhou/game/enemy.py b/pytouhou/game/enemy.py --- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -108,11 +108,15 @@ class Enemy(object): launch_angle -= angle * (bullets_per_shot - 1) / 2. bullets = self._game_state.bullets + nb_bullets_max = self._game_state.nb_bullets_max for shot_nb in range(number_of_shots): shot_speed = speed if shot_nb == 0 else speed + (speed2 - speed) * float(shot_nb) / float(number_of_shots) bullet_angle = launch_angle for bullet_nb in range(bullets_per_shot): + if nb_bullets_max is not None and len(bullets) == nb_bullets_max: + break + if type_ == 75: # 102h.exe@0x4138cf bullet_angle = self._game_state.prng.rand_double() * (launch_angle - angle) + angle if type_ in (74, 75): # 102h.exe@0x4138cf diff --git a/pytouhou/game/game.py b/pytouhou/game/game.py --- a/pytouhou/game/game.py +++ b/pytouhou/game/game.py @@ -23,15 +23,16 @@ from pytouhou.game.enemy import Enemy class GameState(object): __slots__ = ('resource_loader', 'bullets', 'players', 'rank', 'difficulty', 'frame', - 'stage', 'boss', 'prng', 'bullet_types', 'characters') + 'stage', 'boss', 'prng', 'bullet_types', 'characters', 'nb_bullets_max') def __init__(self, resource_loader, players, stage, rank, difficulty, - bullet_types, characters): + bullet_types, characters, nb_bullets_max): self.resource_loader = resource_loader self.bullet_types = bullet_types self.characters = characters self.bullets = [] + self.nb_bullets_max = nb_bullets_max self.stage = stage self.players = players @@ -45,10 +46,10 @@ class GameState(object): class Game(object): def __init__(self, resource_loader, player_states, stage, rank, difficulty, - bullet_types, characters): + bullet_types, characters, nb_bullets_max=None): self.game_state = GameState(resource_loader, player_states, stage, rank, difficulty, - bullet_types, characters) + bullet_types, characters, nb_bullets_max) self.players = [Player(player_state, characters[player_state.character]) for player_state in player_states] self.enemies = [] diff --git a/pytouhou/game/games.py b/pytouhou/game/games.py --- a/pytouhou/game/games.py +++ b/pytouhou/game/games.py @@ -39,5 +39,5 @@ class EoSDGame(Game): Character(player01, 5., 2.5, 2.5)] Game.__init__(self, resource_loader, players, stage, rank, difficulty, - bullet_types, characters) + bullet_types, characters, nb_bullets_max=640)