Added adorable pomeranian sprites
authorJustin Worthe <justin@worthe-it.co.za>
Sat, 30 Jun 2018 12:25:46 +0000 (14:25 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Sat, 30 Jun 2018 12:25:46 +0000 (14:25 +0200)
src/main.rs
src_assets/sprites/Pom.png [new file with mode: 0644]
src_assets/sprites/Sleepypug1.png
src_assets/sprites/Sleepypug2.png
src_assets/sprites/Sleepypug3.png
src_assets/sprites/Sleepypug4.png

index a4b3181..00b7807 100644 (file)
@@ -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
                 );
             }
         }
diff --git a/src_assets/sprites/Pom.png b/src_assets/sprites/Pom.png
new file mode 100644 (file)
index 0000000..829c879
Binary files /dev/null and b/src_assets/sprites/Pom.png differ
index 00d275a..438c5de 100644 (file)
Binary files a/src_assets/sprites/Sleepypug1.png and b/src_assets/sprites/Sleepypug1.png differ
index 134b494..e68b06c 100644 (file)
Binary files a/src_assets/sprites/Sleepypug2.png and b/src_assets/sprites/Sleepypug2.png differ
index 579e617..e527134 100644 (file)
Binary files a/src_assets/sprites/Sleepypug3.png and b/src_assets/sprites/Sleepypug3.png differ
index 6bb2c5d..88a0508 100644 (file)
Binary files a/src_assets/sprites/Sleepypug4.png and b/src_assets/sprites/Sleepypug4.png differ