Mercurial > touhou
comparison src/th06/enemy.rs @ 688:1adecaddf442
ecl_vm: implement SetBulletInterval and SetBulletIntervalEx.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 17 Aug 2019 13:50:54 +0200 |
parents | ac092b70c39a |
children | 482d81f50a11 |
comparison
equal
deleted
inserted
replaced
687:ac092b70c39a | 688:1adecaddf442 |
---|---|
204 pub(crate) death_flags: u32, | 204 pub(crate) death_flags: u32, |
205 pub(crate) current_laser_id: u32, | 205 pub(crate) current_laser_id: u32, |
206 pub(crate) low_life_trigger: Option<u32>, | 206 pub(crate) low_life_trigger: Option<u32>, |
207 pub(crate) timeout: Option<u32>, | 207 pub(crate) timeout: Option<u32>, |
208 pub(crate) remaining_lives: u32, | 208 pub(crate) remaining_lives: u32, |
209 pub(crate) bullet_launch_interval: u32, | 209 bullet_launch_interval: u32, |
210 pub(crate) bullet_launch_timer: u32, | 210 bullet_launch_timer: u32, |
211 pub(crate) death_anim: i32, | 211 pub(crate) death_anim: i32, |
212 pub(crate) direction: Direction, | 212 pub(crate) direction: Direction, |
213 pub(crate) update_mode: u32, | 213 pub(crate) update_mode: u32, |
214 | 214 |
215 // Bools. | 215 // Bools. |
347 if !self.delay_attack { | 347 if !self.delay_attack { |
348 bullet.fire(); | 348 bullet.fire(); |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 /// Sets the bullet launch interval. | |
353 pub(crate) fn set_bullet_launch_interval(&mut self, rand_start: u32, interval: i32) { | |
354 let coeff_interval = interval / 5; | |
355 let difficulty_modifier = coeff_interval + (-coeff_interval * 2) * self.get_difficulty() / 32; | |
356 self.bullet_launch_interval = (interval + difficulty_modifier) as u32; | |
357 self.bullet_launch_timer = rand_start % self.bullet_launch_interval; | |
358 } | |
359 | |
352 /// Run all interpolators and such, and update internal variables once per | 360 /// Run all interpolators and such, and update internal variables once per |
353 /// frame. | 361 /// frame. |
354 pub fn update(&mut self) { | 362 pub fn update(&mut self) { |
355 let Position { mut x, mut y } = self.pos; | 363 let Position { mut x, mut y } = self.pos; |
356 | 364 |
400 } | 408 } |
401 } | 409 } |
402 | 410 |
403 self.pos = Position { x, y }; | 411 self.pos = Position { x, y }; |
404 | 412 |
413 if self.bullet_launch_interval != 0 { | |
414 if self.bullet_launch_timer == 0 { | |
415 self.bullet_attributes.fire(); | |
416 self.bullet_launch_timer = self.bullet_launch_interval; | |
417 } | |
418 self.bullet_launch_timer += 1; | |
419 self.bullet_launch_timer %= self.bullet_launch_interval; | |
420 } | |
421 | |
405 self.frame += 1; | 422 self.frame += 1; |
406 } | 423 } |
407 | 424 |
408 pub(crate) fn get_rank(&self) -> Rank { | 425 pub(crate) fn get_rank(&self) -> Rank { |
409 let game = self.game.upgrade().unwrap(); | 426 let game = self.game.upgrade().unwrap(); |