Skip to content

Commit

Permalink
feat: support reset current level
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jan 17, 2024
1 parent 4bc9bc1 commit 66bda65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ A sokoban with a solver.
### Keyboard

| Key | Action |
|------------------------|-----------------------------------|
| ---------------------- | --------------------------------- |
| `W`/`A`/`S`/`D` | Move the character |
| Arrow keys | Move the character |
| `[`/`]` | Switch to the previous/next level |
| `Ctrl` + `Z` | Undo last push |
| `Ctrl` + `Shift` + `Z` | Redo last push |
| `Esc` | Reset current level |
| `-`/`=` | Zoom in/out |
| `Ctrl` + `V` | Import levels from clipboard |
| `Ctrl` + `C` | Export level to clipboard |
Expand Down
9 changes: 9 additions & 0 deletions src/systems/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub enum Action {
Undo,
Redo,

ResetLevel,
PreviousLevel,
NextLevel,

Expand Down Expand Up @@ -95,6 +96,10 @@ impl Action {
]),
Self::Redo,
),
(
UserInput::Single(InputKind::Keyboard(KeyCode::Escape)),
Self::ResetLevel,
),
(
UserInput::Single(InputKind::Keyboard(KeyCode::BracketLeft)),
Self::PreviousLevel,
Expand Down Expand Up @@ -298,6 +303,10 @@ pub fn handle_other_action(
settings.instant_move = !settings.instant_move;
}

if action_state.just_pressed(Action::ResetLevel) {
**level_id = **level_id;
}

let database = database.lock().unwrap();
if action_state.just_pressed(Action::PreviousLevel) {
player_movement.directions.clear();
Expand Down

0 comments on commit 66bda65

Please sign in to comment.