summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 857e744..c98c80e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,7 +32,8 @@ struct BugBasherGame {
lives: i64,
game_over: bool,
time_to_next_bug: f64,
- total_time: f64
+ total_time: f64,
+ cursor_pos: Vec2d
}
impl App<AssetId> for BugBasherGame {
@@ -86,6 +87,9 @@ impl App<AssetId> for BugBasherGame {
bug.alive = false;
}
},
+ InputEvent::MouseMotion(x, y) => {
+ self.cursor_pos = Vec2d::new(x,y);
+ },
InputEvent::KeyPressed(KeyCode::Return) => {
self.reset();
},
@@ -130,6 +134,14 @@ impl App<AssetId> for BugBasherGame {
BugBasherGame::print_string(renderer, &points_str, Alignment::Center, 0., -25.);
}
}
+
+ {
+ let mut renderer = renderer.sprite_mode();
+ renderer.draw(
+ &Affine::translate(self.cursor_pos.x, self.cursor_pos.y),
+ SpriteId::Cursor
+ );
+ }
}
}
@@ -149,7 +161,8 @@ impl BugBasherGame {
lives: 0,
game_over: true,
time_to_next_bug: 0.,
- total_time: 0.
+ total_time: 0.,
+ cursor_pos: Vec2d::new(0.,0.)
};
game.reset();
game