From 65606557f2f2de430f979d76c46599a4c6f0b224 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sat, 9 Nov 2024 21:18:10 +0200 Subject: [PATCH] removed uncommented code (it sucks) --- src/player.rs | 71 +++++---------------------------------------------- 1 file changed, 6 insertions(+), 65 deletions(-) diff --git a/src/player.rs b/src/player.rs index 3f16344..5c1ccd5 100644 --- a/src/player.rs +++ b/src/player.rs @@ -41,18 +41,6 @@ fn player_movement( mut query: Query<(&mut Velocity, &GroundDetection, &mut Player, &mut Sprite), With>, input: Res>, ) { - // let movement_direction = - // if input.just_pressed(KeyCode::KeyW) || input.just_pressed(KeyCode::Space) { - // GridCoords::new(0, 1) - // } else if input.just_pressed(KeyCode::KeyA) { - // GridCoords::new(-1, 0) - // } else if input.just_pressed(KeyCode::KeyS) { - // GridCoords::new(0, -1) - // } else if input.just_pressed(KeyCode::KeyD) { - // GridCoords::new(1, 0) - // } else { - // return; - // }; for (mut velocity, ground_detection, mut player, mut p_sprite) in &mut query { let right = if input.pressed(KeyCode::KeyD) { player.direction = Facing::Right; @@ -68,8 +56,12 @@ fn player_movement( }; match player.direction { - Facing::Right => {p_sprite.flip_x = false;}, - Facing::Left => {p_sprite.flip_x = true;}, + Facing::Right => { + p_sprite.flip_x = false; + } + Facing::Left => { + p_sprite.flip_x = true; + } } // gotta query for sprite to control how the player "appears" to look in either direction @@ -81,55 +73,4 @@ fn player_movement( } } - // for mut player_grid_coords in players.iter_mut() { - // let destination = *player_grid_coords + movement_direction; - // if !level_walls.in_wall(&destination) { - // *player_grid_coords = destination; - // } - // } } - -// #[derive(Default, Resource)] -// struct LevelWalls { -// wall_locations: HashSet, -// level_width: i32, -// level_height: i32, -// } -// impl LevelWalls { -// fn in_wall(&self, grid_coords: &GridCoords) -> bool { -// grid_coords.x < 0 -// || grid_coords.y < 0 -// || grid_coords.x >= self.level_width -// || grid_coords.y >= self.level_height -// || self.wall_locations.contains(grid_coords) -// } -// } - -// fn cache_wall_locations( -// mut level_walls: ResMut, -// mut level_events: EventReader, -// walls: Query<&GridCoords, With>, -// ldtk_project_entities: Query<&Handle>, -// ldtk_project_assets: Res>, -// ) { -// for level_event in level_events.read() { -// if let LevelEvent::Spawned(level_iid) = level_event { -// let ldtk_project = ldtk_project_assets -// .get(ldtk_project_entities.single()) -// .expect("LdtkProject should be loaded when level is spawned"); -// let level = ldtk_project -// .get_raw_level_by_iid(level_iid.get()) -// .expect("spawned level should exist in project"); - -// let wall_locations = walls.iter().copied().collect(); - -// let new_level_walls = LevelWalls { -// wall_locations, -// level_width: level.px_wid / crate::GRID_SIZE, -// level_height: level.px_hei / crate::GRID_SIZE, -// }; - -// *level_walls = new_level_walls; -// } -// } -// }