summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-06-03 21:01:42 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-06-03 21:01:42 +0200
commitcee4589ff116394b94643b37e251c2be67fe369c (patch)
tree66a1b9d1799b7072382f77abe1bdcee0bf1303b6 /src/main.rs
parent7a8fe60eb17d66771b153280b76546bcf46a9c7e (diff)
Added a custom cursor
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