diff options
| author | Raymond Hogenson <rhogenson@posteo.net> | 2018-08-24 18:09:36 -0400 |
|---|---|---|
| committer | Raymond Hogenson <rhogenson@posteo.net> | 2018-08-24 18:09:36 -0400 |
| commit | d98c24f00ffe08a067040b7efaa934c2efc1bfac (patch) | |
| tree | 586324ba26110ae49dc0356dd4a7af6151ca9d3b /src/gates.rs | |
| parent | b9a6da7ccabb972074f09d686dc78f9643accfac (diff) | |
| download | stallman-shooter-d98c24f00ffe08a067040b7efaa934c2efc1bfac.tar.zst | |
Load the images directly into the executable
Cool, haha. We did it.
I also changed a bunch of random shit.
Diffstat (limited to 'src/gates.rs')
| -rw-r--r-- | src/gates.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/gates.rs b/src/gates.rs index def618a..99133c3 100644 --- a/src/gates.rs +++ b/src/gates.rs @@ -1,4 +1,4 @@ -extern crate rand; +/xtern crate rand; extern crate std; use super::state; @@ -79,7 +79,7 @@ impl state::StraightBullet for GatesBullet { } fn random_bullet<T: state::Enemy<GatesBullet>>(enemy: &T) -> GatesBullet { - let multiplier = 2. + 2.*(1. - enemy.health()); + let multiplier = 2. + 3.*(1. - enemy.health()); let theta: f64 = rand::random::<f64>()*2.*std::f64::consts::PI/3. + std::f64::consts::PI/6.; let dx = f64::cos(theta) * multiplier; let dy = f64::sin(theta) * multiplier; @@ -108,8 +108,8 @@ impl state::Enemy<GatesBullet> for Gates { Gates { x: 200., y: 40., v_x: 0., v_y: 0., a_x: 0., a_y: 0., target_x: 200., target_y: 40., health: 1. } } fn act(&mut self, count: u64) -> Vec<GatesBullet> { - let max_accel = 0.25; - let max_velocity = 5.; + let max_accel = (1. - self.health) * 0.75 + 0.25; + let max_velocity = (1. - self.health) * 5. + 5.; let dx = self.target_x - self.x; let dy = self.target_y - self.y; /* If we've arrived (close and stopped) */ @@ -149,18 +149,21 @@ impl state::Enemy<GatesBullet> for Gates { self.v_y += self.a_y; self.y += self.v_y; if count % 20 == 0 { - let num_bullets; - if self.health >= 0.8 { - num_bullets = 4; + let num_bullets = if self.health >= 0.8 { + 5 + } else if self.health >= 0.7 { + 6 } else if self.health >= 0.5 { - num_bullets = 5; + 7 + } else if self.health >= 0.4 { + 8 } else if self.health >= 0.3 { - num_bullets = 6; + 9 } else if self.health >= 0.2 { - num_bullets = 7; + 10 } else { - num_bullets = 8; - } + 11 + }; let mut result = Vec::new(); for _ in 0..num_bullets { result.push(random_bullet(&*self)); |
