comparison src/th06/enemy.rs @ 667:904849807fd8

Implement update_mode 1 on enemy.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 12 Aug 2019 15:09:34 +0200
parents 838d9402b12f
children 140ee7de6d90
comparison
equal deleted inserted replaced
666:838d9402b12f 667:904849807fd8
252 /// frame. 252 /// frame.
253 pub fn update(&mut self) { 253 pub fn update(&mut self) {
254 let Position { mut x, mut y } = self.pos; 254 let Position { mut x, mut y } = self.pos;
255 255
256 let speed = if self.update_mode == 1 { 256 let speed = if self.update_mode == 1 {
257 0. 257 let mut speed = 0.;
258 if let Some(interpolator) = &self.interpolator {
259 let values = interpolator.values(self.frame as u16);
260 x = values[0];
261 y = values[1];
262 }
263 if let Some(interpolator) = &self.speed_interpolator {
264 let values = interpolator.values(self.frame as u16);
265 speed = values[0];
266 }
267 speed
258 } else { 268 } else {
259 let speed = self.speed; 269 let speed = self.speed;
260 self.speed += self.acceleration; 270 self.speed += self.acceleration;
261 self.angle += self.rotation_speed; 271 self.angle += self.rotation_speed;
262 speed 272 speed