comparison src/th06/enemy.rs @ 689:482d81f50a11

ecl_vm: fix panic when bullet_interval is zero (disabled).
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2019 13:54:52 +0200
parents 1adecaddf442
children eecb8626f472
comparison
equal deleted inserted replaced
688:1adecaddf442 689:482d81f50a11
352 /// Sets the bullet launch interval. 352 /// Sets the bullet launch interval.
353 pub(crate) fn set_bullet_launch_interval(&mut self, rand_start: u32, interval: i32) { 353 pub(crate) fn set_bullet_launch_interval(&mut self, rand_start: u32, interval: i32) {
354 let coeff_interval = interval / 5; 354 let coeff_interval = interval / 5;
355 let difficulty_modifier = coeff_interval + (-coeff_interval * 2) * self.get_difficulty() / 32; 355 let difficulty_modifier = coeff_interval + (-coeff_interval * 2) * self.get_difficulty() / 32;
356 self.bullet_launch_interval = (interval + difficulty_modifier) as u32; 356 self.bullet_launch_interval = (interval + difficulty_modifier) as u32;
357 self.bullet_launch_timer = rand_start % self.bullet_launch_interval; 357 if self.bullet_launch_interval > 0 {
358 self.bullet_launch_timer = rand_start % self.bullet_launch_interval;
359 }
358 } 360 }
359 361
360 /// Run all interpolators and such, and update internal variables once per 362 /// Run all interpolators and such, and update internal variables once per
361 /// frame. 363 /// frame.
362 pub fn update(&mut self) { 364 pub fn update(&mut self) {