diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-06-30 14:25:46 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-06-30 14:25:46 +0200 |
commit | 7d9452a0c3f3d292019d81844ccfbcdcc734d674 (patch) | |
tree | b555441fec49136912f0150baef32ace39c58567 /src/main.rs | |
parent | dbeffaaac544e56c51f4640fa0113ddbe6e13c8a (diff) |
Added adorable pomeranian sprites
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index a4b3181..00b7807 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ extern crate rand; use rand::distributions::IndependentSample; use rand::Isaac64Rng; use std::f64::consts::PI; +use std::f64::consts::FRAC_PI_2; mod asset_id { include!(concat!(env!("OUT_DIR"), "/asset_id.rs")); } use asset_id::*; @@ -65,7 +66,9 @@ impl App<AssetId> for BugBasherGame { f64::max(1. - ((self.total_time as f64 - 30.) * 0.05), 0.5) } else if self.total_time < 90. { f64::max(0.5 - ((self.total_time as f64 - 60.) * 0.05), 0.3) - } + } else { + f64::max(0.3 - ((self.total_time as f64 - 90.) * 0.005), 0.2) + }; let sd = mean / 3.; let time_dist = rand::distributions::Normal::new(mean, sd); @@ -118,13 +121,19 @@ impl App<AssetId> for BugBasherGame { { let mut renderer = renderer.sprite_mode(); renderer.draw( - &Affine::translate(self.home.pos.x, self.home.pos.y).pre_scale(0.5), + &Affine::translate(self.home.pos.x, self.home.pos.y), self.home.sprite ); for bug in &self.bugs { + let affine = if bug.rotation <= FRAC_PI_2 && bug.rotation >= -FRAC_PI_2 { + Affine::translate(bug.pos.x, bug.pos.y).pre_rotate(bug.rotation) + } else { + Affine::translate(bug.pos.x, bug.pos.y).pre_rotate(bug.rotation).pre_scale_axes(1., -1.) + }; + renderer.draw( - &Affine::translate(bug.pos.x, bug.pos.y).pre_rotate(bug.rotation), - SpriteId::Bug + &affine, + SpriteId::Pom ); } } |