removed uncommented code (it sucks)
This commit is contained in:
@@ -41,18 +41,6 @@ fn player_movement(
|
|||||||
mut query: Query<(&mut Velocity, &GroundDetection, &mut Player, &mut Sprite), With<Player>>,
|
mut query: Query<(&mut Velocity, &GroundDetection, &mut Player, &mut Sprite), With<Player>>,
|
||||||
input: Res<ButtonInput<KeyCode>>,
|
input: Res<ButtonInput<KeyCode>>,
|
||||||
) {
|
) {
|
||||||
// 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 {
|
for (mut velocity, ground_detection, mut player, mut p_sprite) in &mut query {
|
||||||
let right = if input.pressed(KeyCode::KeyD) {
|
let right = if input.pressed(KeyCode::KeyD) {
|
||||||
player.direction = Facing::Right;
|
player.direction = Facing::Right;
|
||||||
@@ -68,8 +56,12 @@ fn player_movement(
|
|||||||
};
|
};
|
||||||
|
|
||||||
match player.direction {
|
match player.direction {
|
||||||
Facing::Right => {p_sprite.flip_x = false;},
|
Facing::Right => {
|
||||||
Facing::Left => {p_sprite.flip_x = true;},
|
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
|
// 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<GridCoords>,
|
|
||||||
// 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<LevelWalls>,
|
|
||||||
// mut level_events: EventReader<LevelEvent>,
|
|
||||||
// walls: Query<&GridCoords, With<Wall>>,
|
|
||||||
// ldtk_project_entities: Query<&Handle<LdtkProject>>,
|
|
||||||
// ldtk_project_assets: Res<Assets<LdtkProject>>,
|
|
||||||
// ) {
|
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user