Mercurial > touhou
changeset 198:13918723d1bc
Modify difficulty when it has to.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 30 Oct 2011 11:31:19 -0700 |
parents | e1bc8c4cbb1a |
children | 8ec34c56fed0 |
files | pytouhou/game/game.py pytouhou/game/item.py pytouhou/game/player.py |
diffstat | 3 files changed, 33 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/game/game.py +++ b/pytouhou/game/game.py @@ -45,6 +45,9 @@ class Game(object): self.stage = stage self.rank = rank self.difficulty = difficulty + self.difficulty_counter = 0 + self.difficulty_min = 12 if rank == 0 else 10 + self.difficulty_max = 20 if rank == 0 else 32 self.boss = None self.spellcard = None self.bonus_list = [0,0,1,0,1,0,0,1,1,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,0,2] @@ -62,6 +65,20 @@ class Game(object): self.next_bonus = self.prng.rand_uint16() % 8 + def modify_difficulty(self, diff): + self.difficulty_counter += diff + while self.difficulty_counter < 0: + self.difficulty -= 1 + self.difficulty_counter += 100 + while self.difficulty_counter >= 100: + self.difficulty += 1 + self.difficulty_counter -= 100 + if self.difficulty < self.difficulty_min: + self.difficulty = self.difficulty_min + elif self.difficulty > self.difficulty_max: + self.difficulty = self.difficulty_max + + def drop_bonus(self, x, y, _type, end_pos=None): player = self.players[0] #TODO if _type > 6: @@ -96,6 +113,8 @@ class Game(object): def run_iter(self, keystate): # 1. VMs. self.ecl_runner.run_iter() + if self.frame % (32*60) == (32*60): #TODO: check if that is really that frame. + self.modify_difficulty(+100) # 2. Filter out destroyed enemies self.enemies = [enemy for enemy in self.enemies if not enemy._removed] @@ -236,6 +255,7 @@ class Game(object): bullet.grazed = True player.state.graze += 1 player.state.score += 500 # found experimentally + self.modify_difficulty(+6) 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”. @@ -268,7 +288,13 @@ class Game(object): self.players_bullets = [bullet for bullet in self.players_bullets if bullet.is_visible(384, 448)] # Filter out-of-scren items - self.items = [item for item in self.items if item.y < 448] + items = [] + for item in self.items: + if item.y < 448: + items.append(item) + else: + self.modify_difficulty(-3) + self.items = items # Disable boss mode if it is dead/it has timeout if self.boss and self.boss._removed:
--- a/pytouhou/game/item.py +++ b/pytouhou/game/item.py @@ -75,18 +75,22 @@ class Item(object): score = 51200 player_state.power_bonus = bonus player_state.score += score + self._game.modify_difficulty(+1) elif self._type == 1: # point player_state.points += 1 if player_state.y < 128: #TODO: find the exact poc. score = 100000 + self._game.modify_difficulty(+30) else: score = 0 #TODO: find the formula. + self._game.modify_difficulty(+3) player_state.score += score elif self._type == 3: # bomb if player_state.bombs < 8: player_state.bombs += 1 + self._game.modify_difficulty(+5) elif self._type == 4: # full power player_state.score += 1000 @@ -95,6 +99,7 @@ class Item(object): elif self._type == 5: # 1up if player_state.lives < 8: player_state.lives += 1 + self._game.modify_difficulty(+200) elif self._type == 6: # star player_state.score += 500
--- a/pytouhou/game/player.py +++ b/pytouhou/game/player.py @@ -93,6 +93,7 @@ class Player(object): if not self.state.invulnerable_time and not self.death_time and self.state.touchable: # Border Between Life and Death self.death_time = self._game.frame self._game.new_death((self.state.x, self.state.y), 2) + self._game.modify_difficulty(-1600) for i in range(16): self._game.new_particle((self.state.x, self.state.y), 2, 4., 256) #TODO: find the real size and range.