Mercurial > touhou
comparison 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 |
comparison
equal
deleted
inserted
replaced
181:184196480f59 | 182:20843875ad8f |
---|---|
40 self.max_life = life | 40 self.max_life = life |
41 self.touchable = True | 41 self.touchable = True |
42 self.damageable = True | 42 self.damageable = True |
43 self.death_flags = 0 | 43 self.death_flags = 0 |
44 self.boss = False | 44 self.boss = False |
45 self.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0) | |
45 self.extended_bullet_attributes = (0, 0, 0, 0, 0., 0., 0., 0.) | 46 self.extended_bullet_attributes = (0, 0, 0, 0, 0., 0., 0., 0.) |
46 self.bullet_attributes = None | 47 self.bullet_attributes = None |
47 self.bullet_launch_offset = (0, 0) | 48 self.bullet_launch_offset = (0, 0) |
48 self.death_callback = None | 49 self.death_callback = None |
49 self.boss_callback = None | 50 self.boss_callback = None |
75 | 76 |
76 | 77 |
77 def set_bullet_attributes(self, type_, anim, sprite_idx_offset, | 78 def set_bullet_attributes(self, type_, anim, sprite_idx_offset, |
78 bullets_per_shot, number_of_shots, speed, speed2, | 79 bullets_per_shot, number_of_shots, speed, speed2, |
79 launch_angle, angle, flags): | 80 launch_angle, angle, flags): |
81 | |
82 # Apply difficulty-specific modifiers | |
83 speed_a, speed_b, nb_a, nb_b, shots_a, shots_b = self.difficulty_coeffs | |
84 diff_coeff = self._game.difficulty / 32. | |
85 | |
86 speed += speed_a * (1. - diff_coeff) + speed_b * diff_coeff | |
87 speed2 += (speed_a * (1. - diff_coeff) + speed_b * diff_coeff) / 2. | |
88 bullets_per_shot += int(nb_a * (1. - diff_coeff) + nb_b * diff_coeff) | |
89 number_of_shots += int(shots_a * (1. - diff_coeff) + shots_b * diff_coeff) | |
90 | |
80 self.bullet_attributes = (type_, anim, sprite_idx_offset, bullets_per_shot, | 91 self.bullet_attributes = (type_, anim, sprite_idx_offset, bullets_per_shot, |
81 number_of_shots, speed, speed2, launch_angle, | 92 number_of_shots, speed, speed2, launch_angle, |
82 angle, flags) | 93 angle, flags) |
83 if not self.delay_attack: | 94 if not self.delay_attack: |
84 self.fire() | 95 self.fire() |
96 | |
97 | |
98 def set_bullet_launch_interval(self, value, start=0.): | |
99 # Apply difficulty-specific modifiers: | |
100 value *= 1. - .4 * (self._game.difficulty - 16.) / 32. | |
101 | |
102 self.bullet_launch_interval = int(value) | |
103 self.bullet_launch_timer = int(value * start) | |
104 print(self.bullet_launch_interval, self.bullet_launch_timer) | |
85 | 105 |
86 | 106 |
87 def fire(self): | 107 def fire(self): |
88 (type_, type_idx, sprite_idx_offset, bullets_per_shot, number_of_shots, | 108 (type_, type_idx, sprite_idx_offset, bullets_per_shot, number_of_shots, |
89 speed, speed2, launch_angle, angle, flags) = self.bullet_attributes | 109 speed, speed2, launch_angle, angle, flags) = self.bullet_attributes |