From 901d457f815ac9022b1a47dc17308511a07d9f98 Mon Sep 17 00:00:00 2001 From: Glaeder Date: Sat, 6 Jul 2024 19:56:33 +0200 Subject: [PATCH] Formatted and fixed clippy with nightly --- .gitignore | 2 +- src/activities/house/grid.rs | 4 ++-- src/activities/house/mod.rs | 2 +- src/activities/house/player.rs | 20 ++++++++++---------- src/activities/mod.rs | 3 ++- src/game.rs | 6 +++--- src/main.rs | 5 ++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 5b325cd..0b4fc31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target -shell.nix +*.nix .vscode/ \ No newline at end of file diff --git a/src/activities/house/grid.rs b/src/activities/house/grid.rs index 5c9cee7..114eace 100644 --- a/src/activities/house/grid.rs +++ b/src/activities/house/grid.rs @@ -3,7 +3,7 @@ use comfy::*; #[derive(Debug)] pub struct Grid { pub nodes: Vec, - pub connections: Vec<(usize, usize)>, + pub connections: Vec<(usize, usize)> } impl Default for Grid { @@ -22,7 +22,7 @@ impl Grid { vec2(-10.0, 0.0), vec2(10.0, 10.0), ], - connections: vec![(0, 1), (1, 2), (1, 3), (0, 4), (0, 5), (5, 1), (6, 7)], + connections: vec![(0, 1), (1, 2), (1, 3), (0, 4), (0, 5), (5, 1), (6, 7)] }; grid.sanitize(); diff --git a/src/activities/house/mod.rs b/src/activities/house/mod.rs index 13ac5f0..643e666 100644 --- a/src/activities/house/mod.rs +++ b/src/activities/house/mod.rs @@ -7,7 +7,7 @@ use player::Player; #[derive(Debug, Default)] pub struct HouseState { grid: Grid, - player: Player, + player: Player } pub fn draw(state: &crate::State, _engine: &comfy::EngineContext) { diff --git a/src/activities/house/player.rs b/src/activities/house/player.rs index f391c82..eb60107 100644 --- a/src/activities/house/player.rs +++ b/src/activities/house/player.rs @@ -7,7 +7,7 @@ pub struct Player { position: Vec2, speed: f32, connection: usize, - next_connections: Vec, + next_connections: Vec } impl Default for Player { @@ -16,7 +16,7 @@ impl Default for Player { position: Default::default(), speed: 10.0, connection: 0, - next_connections: vec![1, 2, 3], + next_connections: vec![1, 2, 3] } } } @@ -40,7 +40,7 @@ fn move_player(player: &mut Player, allowed_movement: (bool, bool, bool, bool)) allow_up_movement, allow_down_movement, allow_left_movement, - allow_right_movement, + allow_right_movement ) = allowed_movement; if allow_up_movement && is_key_down(KeyCode::Up) { @@ -77,7 +77,7 @@ fn get_allowed_movement(player: &Player, grid: &Grid) -> (bool, bool, bool, bool mut allow_up_movement, mut allow_down_movement, mut allow_left_movement, - mut allow_right_movement, + mut allow_right_movement ) = get_allowed_connection_movement(&player.position, node_1, node_2); for conn in &player.next_connections { @@ -89,26 +89,26 @@ fn get_allowed_movement(player: &Player, grid: &Grid) -> (bool, bool, bool, bool next_allow_up_movement, next_allow_down_movement, next_allow_left_movement, - next_allow_right_movement, + next_allow_right_movement ) = get_allowed_connection_movement(&player.position, next_node_1, next_node_2); ( allow_up_movement, allow_down_movement, allow_left_movement, - allow_right_movement, + allow_right_movement ) = ( allow_up_movement || next_allow_up_movement, allow_down_movement || next_allow_down_movement, allow_left_movement || next_allow_left_movement, - allow_right_movement || next_allow_right_movement, + allow_right_movement || next_allow_right_movement ); } ( allow_up_movement, allow_down_movement, allow_left_movement, - allow_right_movement, + allow_right_movement ) } } @@ -117,7 +117,7 @@ fn get_allowed_movement(player: &Player, grid: &Grid) -> (bool, bool, bool, bool fn get_allowed_connection_movement( player_position: &Vec2, node_1: &Vec2, - node_2: &Vec2, + node_2: &Vec2 ) -> (bool, bool, bool, bool) { let allow_left_movement = { if node_1.x <= node_2.x { @@ -171,7 +171,7 @@ fn get_allowed_connection_movement( allow_up_movement, allow_down_movement, allow_left_movement, - allow_right_movement, + allow_right_movement ) } diff --git a/src/activities/mod.rs b/src/activities/mod.rs index 906af6e..dfa2b9e 100644 --- a/src/activities/mod.rs +++ b/src/activities/mod.rs @@ -5,5 +5,6 @@ pub mod overworld; pub enum Activity { #[default] House, - Overworld, + #[allow(dead_code)] + Overworld } diff --git a/src/game.rs b/src/game.rs index 01e7f4d..a91fe39 100644 --- a/src/game.rs +++ b/src/game.rs @@ -2,19 +2,19 @@ use comfy::*; use crate::{ activities::{house, overworld, Activity}, - State, + State }; pub fn update(state: &mut State, engine: &mut EngineContext) { match state.activity { Activity::House => house::update(state, engine), - Activity::Overworld => overworld::update(state, engine), + Activity::Overworld => overworld::update(state, engine) } } pub fn draw(state: &State, engine: &EngineContext) { match state.activity { Activity::House => house::draw(state, engine), - Activity::Overworld => overworld::draw(state, engine), + Activity::Overworld => overworld::draw(state, engine) } } diff --git a/src/main.rs b/src/main.rs index 23315bd..863ddb3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,7 @@ mod activities; mod game; -use activities::house::HouseState; -use activities::Activity; +use activities::{house::HouseState, Activity}; use comfy::*; const GAME_NAME: &str = "Powercreep"; @@ -10,7 +9,7 @@ const GAME_NAME: &str = "Powercreep"; #[derive(Debug, Default)] struct State { activity: Activity, - house: HouseState, + house: HouseState } impl GameLoop for State {