summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 55c8594..6ed2dbf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
+#![warn(clippy)]
+
#[macro_use]
extern crate gate;
@@ -46,7 +48,7 @@ impl App<AssetId> for BugBasherGame {
fn advance(&mut self, seconds: f64, _ctx: &mut AppContext<AssetId>) {
if !self.game_over {
self.bugs.retain(|b| b.alive);
- for bug in self.bugs.iter_mut() {
+ for bug in &mut self.bugs {
bug.advance(seconds);
if self.home.touches_circle(bug) {
bug.alive = false;
@@ -92,8 +94,8 @@ impl App<AssetId> for BugBasherGame {
match key {
KeyCode::MouseLeft => {
let mut hit = false;
- for bug in self.bugs.iter_mut().filter(|bug| bug.touches_point(Vec2d { x, y })) {
- if !self.game_over && bug.alive == true {
+ for bug in self.bugs.iter_mut().filter(|bug| bug.touches_point(Vec2d::new(x, y))) {
+ if !self.game_over && bug.alive {
self.points += 1;
}
bug.alive = false;
@@ -119,8 +121,8 @@ impl App<AssetId> for BugBasherGame {
{
let points_str = format!("{}", self.points);
let lives_str = format!("{}", self.lives);
- BugBasherGame::print_string(renderer, &points_str, Alignment::Left, 50., app_height - 50.);
- BugBasherGame::print_string(renderer, &lives_str, Alignment::Right, app_width - 50., app_height - 50.);
+ BugBasherGame::print_string(renderer, &points_str, &Alignment::Left, 50., app_height - 50.);
+ BugBasherGame::print_string(renderer, &lives_str, &Alignment::Right, app_width - 50., app_height - 50.);
}
{
let mut renderer = renderer.sprite_mode();
@@ -152,7 +154,7 @@ impl App<AssetId> for BugBasherGame {
}
{
let points_str = format!("{}", self.points);
- BugBasherGame::print_string(renderer, &points_str, Alignment::Center, app_width/2., app_height/2.-25.);
+ BugBasherGame::print_string(renderer, &points_str, &Alignment::Center, app_width/2., app_height/2.-25.);
}
}
@@ -199,7 +201,7 @@ impl BugBasherGame {
self.total_time = 0.;
}
- fn print_string(renderer: &mut Renderer<AssetId>, string: &str, alignment: Alignment, x: f64, y: f64) {
+ fn print_string(renderer: &mut Renderer<AssetId>, string: &str, alignment: &Alignment, x: f64, y: f64) {
let letter_spacing = 45.;
let left = match alignment {
Alignment::Left => x,