Skip to content

Commit

Permalink
refactor: remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Feb 14, 2024
1 parent 5f5181d commit 0e37265
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
12 changes: 4 additions & 8 deletions src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,12 @@ impl Level {
self.get_unchecked(position).intersects(Tile::Wall)
|| initial_crate_positions.contains(position)
});
for &push_direction in [
for push_direction in [
Direction::Up,
Direction::Down,
Direction::Left,
Direction::Right,
]
.iter()
{
] {
let player_position = crate_position - push_direction.to_vector();
if self.get_unchecked(&player_position).intersects(Tile::Wall)
|| !player_reachable_area.contains(&player_position)
Expand All @@ -563,14 +561,12 @@ impl Level {
|| crate_positions.contains(position)
});

for &push_direction in [
for push_direction in [
Direction::Up,
Direction::Down,
Direction::Left,
Direction::Right,
]
.iter()
{
] {
let new_crate_position = state.crate_position + push_direction.to_vector();
let player_position = state.crate_position - push_direction.to_vector();

Expand Down
6 changes: 2 additions & 4 deletions src/systems/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,12 @@ pub fn mouse_input(
paths,
} => {
let mut crate_paths = Vec::new();
for &push_direction in [
for push_direction in [
Direction::Up,
Direction::Down,
Direction::Left,
Direction::Right,
]
.iter()
{
] {
let push_state = PushState {
push_direction,
crate_position: grid_position,
Expand Down

0 comments on commit 0e37265

Please sign in to comment.