changeset 720:cffb0f1531fc

ecl_vm: implemented spellcard QED: Ripple of 495 years
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Wed, 25 Sep 2019 16:59:21 +0200
parents 28e6332b088d
children bbf0da7de481
files src/th06/ecl_vm.rs
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/th06/ecl_vm.rs
+++ b/src/th06/ecl_vm.rs
@@ -988,6 +988,22 @@ impl EclRunner {
                                    rand_y * range_y + enemy.pos.x as f64 - range_y / 2.];
                         enemy.bullet_attributes.fire();
                     }
+                    16 => { // QED: Ripples of 495 years
+                        let mut enemy = self.enemy.borrow_mut();
+                        let game = enemy.game.upgrade().unwrap();
+                        let mut game = game.borrow_mut();
+                        if arg == 0 {
+                            self.frame.floats[3] = 2. - (enemy.life as f32) / 6000.;
+                            self.frame.ints2[1] = ((enemy.life * 240) / 6000 + 40) as i32;
+                        } else {
+                            let fx = (320. - ((enemy.life as f32) * 160.) / 6000.) as f64;
+                            let fy = (128. - ((enemy.life as f32) * 64.) / 6000.) as f64;
+                            let rand_x = game.prng.borrow_mut().get_f64();
+                            let rand_y = game.prng.borrow_mut().get_f64();
+                            self.frame.floats[2] = (rand_x * fx + (192. - fx / 2.)) as f32;
+                            self.frame.floats[3] = (rand_y * fy + (96. - fy / 2.)) as f32;
+                        }
+                    }
                     _ => unimplemented!("spellcards are a bitch and a half")
                 }
             }