Mercurial > touhou
comparison pytouhou/game/enemymanager.py @ 62:1f591adcea04
Fix animation determination (ins_98 stuff) and some interpolation functions
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 24 Aug 2011 21:16:14 +0200 |
parents | 694f25881d0f |
children | e2cb9d434dc2 |
comparison
equal
deleted
inserted
replaced
61:0886994029e4 | 62:1f591adcea04 |
---|---|
95 self.x, self.y = x, y | 95 self.x, self.y = x, y |
96 self.interpolator = Interpolator((x, y)) | 96 self.interpolator = Interpolator((x, y)) |
97 self.interpolator.set_interpolation_start(self.frame, (x, y)) | 97 self.interpolator.set_interpolation_start(self.frame, (x, y)) |
98 | 98 |
99 | 99 |
100 def move_to(self, duration, x, y, z): | 100 def move_to(self, duration, x, y, z, formula): |
101 if not self.interpolator: | 101 if not self.interpolator: |
102 self.interpolator = Interpolator((self.x, self.y)) | 102 self.interpolator = Interpolator((self.x, self.y), formula) |
103 self.interpolator.set_interpolation_start(self.frame, (self.x, self.y)) | 103 self.interpolator.set_interpolation_start(self.frame, (self.x, self.y)) |
104 self.interpolator.set_interpolation_end(self.frame + duration, (x, y)) | 104 self.interpolator.set_interpolation_end(self.frame + duration - 1, (x, y)) |
105 | 105 |
106 | 106 |
107 def stop_in(self, duration): | 107 def stop_in(self, duration): |
108 #TODO: interpolation method and start/stop frame | |
109 # See 97 vs 98 anim conflict | |
108 if not self.speed_interpolator: | 110 if not self.speed_interpolator: |
109 self.speed_interpolator = Interpolator((self.speed,)) | 111 self.speed_interpolator = Interpolator((self.speed,)) |
110 self.speed_interpolator.set_interpolation_start(self.frame, (self.speed,)) | 112 self.speed_interpolator.set_interpolation_start(self.frame, (self.speed,)) |
111 self.speed_interpolator.set_interpolation_end(self.frame + duration, (0.,)) | 113 self.speed_interpolator.set_interpolation_end(self.frame + duration, (0.,)) |
112 | 114 |
169 | 171 |
170 if self.movement_dependant_sprites: | 172 if self.movement_dependant_sprites: |
171 #TODO: is that really how it works? Almost. | 173 #TODO: is that really how it works? Almost. |
172 # Sprite determination is done only once per changement, and is | 174 # Sprite determination is done only once per changement, and is |
173 # superseeded by ins_97. | 175 # superseeded by ins_97. |
174 if x < self.x: | 176 end_left, end_right, left, right = self.movement_dependant_sprites |
175 self.set_anim(self.movement_dependant_sprites[2]) | 177 if x < self.x and self.direction != -1: |
178 self.set_anim(left) | |
176 self.direction = -1 | 179 self.direction = -1 |
177 elif x > self.x: | 180 print('left') |
178 self.set_anim(self.movement_dependant_sprites[3]) | 181 elif x > self.x and self.direction != +1: |
182 self.set_anim(right) | |
179 self.direction = +1 | 183 self.direction = +1 |
180 elif self.direction is not None: | 184 print(left, right) |
181 self.set_anim(self.movement_dependant_sprites[{-1: 0, +1:1}[self.direction]]) | 185 print('right') |
186 elif x == self.x and self.direction is not None: | |
187 self.set_anim({-1: end_left, +1: end_right}[self.direction]) | |
182 self.direction = None | 188 self.direction = None |
183 | 189 |
184 | 190 |
185 if self.screen_box: | 191 if self.screen_box: |
186 xmin, ymin, xmax, ymax = self.screen_box | 192 xmin, ymin, xmax, ymax = self.screen_box |