Formatted and fixed clippy with nightly
This commit is contained in:
parent
ee49fb493f
commit
901d457f81
7 changed files with 21 additions and 21 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
|||
/target
|
||||
shell.nix
|
||||
*.nix
|
||||
.vscode/
|
|
@ -3,7 +3,7 @@ use comfy::*;
|
|||
#[derive(Debug)]
|
||||
pub struct Grid {
|
||||
pub nodes: Vec<Vec2>,
|
||||
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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -7,7 +7,7 @@ pub struct Player {
|
|||
position: Vec2,
|
||||
speed: f32,
|
||||
connection: usize,
|
||||
next_connections: Vec<usize>,
|
||||
next_connections: Vec<usize>
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,5 +5,6 @@ pub mod overworld;
|
|||
pub enum Activity {
|
||||
#[default]
|
||||
House,
|
||||
Overworld,
|
||||
#[allow(dead_code)]
|
||||
Overworld
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue