-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Earthmark/earthmark-dev
Added player, and victory text.
- Loading branch information
Showing
8 changed files
with
465 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,54 @@ | ||
use bevy::prelude::{Input, KeyCode, Query, Res}; | ||
use bevy::prelude::*; | ||
|
||
use super::maze_level::*; | ||
use super::maze_level::{Axis, Direction}; | ||
|
||
pub fn level_navigation<const DIMS: usize>( | ||
mut query: Query<&mut MazeLevel<DIMS>>, | ||
pub fn level_navigation( | ||
level: Option<ResMut<MazeLevel>>, | ||
keys: Res<Input<KeyCode>>, | ||
mut position_event: EventWriter<PositionChanged>, | ||
mut axis_event: EventWriter<AxisChanged>, | ||
) { | ||
if keys.just_pressed(KeyCode::Q) { | ||
for mut level in query.iter_mut() { | ||
if let Some(mut level) = level { | ||
if keys.just_pressed(KeyCode::Q) { | ||
level.shift_axis(Axis::X, Direction::Negative); | ||
axis_event.send(AxisChanged { axis: level.axis() }); | ||
} | ||
} | ||
if keys.just_pressed(KeyCode::E) { | ||
for mut level in query.iter_mut() { | ||
if keys.just_pressed(KeyCode::E) { | ||
level.shift_axis(Axis::X, Direction::Positive); | ||
axis_event.send(AxisChanged { axis: level.axis() }); | ||
} | ||
} | ||
if keys.just_pressed(KeyCode::W) { | ||
for mut level in query.iter_mut() { | ||
if keys.just_pressed(KeyCode::Z) { | ||
level.shift_axis(Axis::Y, Direction::Negative); | ||
axis_event.send(AxisChanged { axis: level.axis() }); | ||
} | ||
if keys.just_pressed(KeyCode::X) { | ||
level.shift_axis(Axis::Y, Direction::Positive); | ||
axis_event.send(AxisChanged { axis: level.axis() }); | ||
} | ||
if keys.just_pressed(KeyCode::W) { | ||
level.move_pos(Axis::X, Direction::Positive); | ||
position_event.send(PositionChanged { | ||
position: level.pos(), | ||
}); | ||
} | ||
} | ||
if keys.just_pressed(KeyCode::S) { | ||
for mut level in query.iter_mut() { | ||
if keys.just_pressed(KeyCode::S) { | ||
level.move_pos(Axis::X, Direction::Negative); | ||
position_event.send(PositionChanged { | ||
position: level.pos(), | ||
}); | ||
} | ||
} | ||
if keys.just_pressed(KeyCode::D) { | ||
for mut level in query.iter_mut() { | ||
if keys.just_pressed(KeyCode::D) { | ||
level.move_pos(Axis::Y, Direction::Positive); | ||
position_event.send(PositionChanged { | ||
position: level.pos(), | ||
}); | ||
} | ||
} | ||
if keys.just_pressed(KeyCode::A) { | ||
for mut level in query.iter_mut() { | ||
if keys.just_pressed(KeyCode::A) { | ||
level.move_pos(Axis::Y, Direction::Negative); | ||
position_event.send(PositionChanged { | ||
position: level.pos(), | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.