Mercurial > touhou
diff pytouhou/game/enemy.py @ 182:20843875ad8f
(Hopefully) use difficulty as it should.
The difficulty[0] (also called rank) varies from 0 to 32 and affects
various parts of the game. The difficulty now impact those parts,
but how it is modified during the gameplay is not clear.
Such changes to the difficulty are not handled yet.
[0] http://en.touhouwiki.net/wiki/Embodiment_of_Scarlet_Devil/Gameplay#Rank
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 25 Oct 2011 01:29:40 +0200 |
parents | 184196480f59 |
children | b6d7ce644f34 |
line wrap: on
line diff
--- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -42,6 +42,7 @@ class Enemy(object): self.damageable = True self.death_flags = 0 self.boss = False + self.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0) self.extended_bullet_attributes = (0, 0, 0, 0, 0., 0., 0., 0.) self.bullet_attributes = None self.bullet_launch_offset = (0, 0) @@ -77,6 +78,16 @@ class Enemy(object): def set_bullet_attributes(self, type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, speed, speed2, launch_angle, angle, flags): + + # Apply difficulty-specific modifiers + speed_a, speed_b, nb_a, nb_b, shots_a, shots_b = self.difficulty_coeffs + diff_coeff = self._game.difficulty / 32. + + speed += speed_a * (1. - diff_coeff) + speed_b * diff_coeff + speed2 += (speed_a * (1. - diff_coeff) + speed_b * diff_coeff) / 2. + bullets_per_shot += int(nb_a * (1. - diff_coeff) + nb_b * diff_coeff) + number_of_shots += int(shots_a * (1. - diff_coeff) + shots_b * diff_coeff) + self.bullet_attributes = (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, speed, speed2, launch_angle, angle, flags) @@ -84,6 +95,15 @@ class Enemy(object): self.fire() + def set_bullet_launch_interval(self, value, start=0.): + # Apply difficulty-specific modifiers: + value *= 1. - .4 * (self._game.difficulty - 16.) / 32. + + self.bullet_launch_interval = int(value) + self.bullet_launch_timer = int(value * start) + print(self.bullet_launch_interval, self.bullet_launch_timer) + + def fire(self): (type_, type_idx, sprite_idx_offset, bullets_per_shot, number_of_shots, speed, speed2, launch_angle, angle, flags) = self.bullet_attributes