Skip to content

Commit 3a060e2

Browse files
committed
Change default to running and shift key to walk
1 parent 626b1b0 commit 3a060e2

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ cargo run --features bevy/dynamic
1818

1919
Gamepads and keyboard are supported.
2020

21-
- Player 1: WASD keys to move, left shift to run
22-
- Player 2: Arrow keys to move, right shift to run
21+
- Player 1: WASD keys to move, left shift to walk
22+
- Player 2: Arrow keys to move, right shift to walk
2323
- Escape to exit
2424

2525
### Building

src/actions.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,25 @@ pub fn handle_movement_input_system(
5757
if input_actions.is_active(Action::Up, player.id) {
5858
new_direction = Some(Direction::North);
5959
new_velocity.y = 1.0;
60-
new_state = CharacterState::Walking;
60+
new_state = CharacterState::Running;
6161
}
6262
if input_actions.is_active(Action::Down, player.id) {
6363
new_direction = Some(Direction::South);
6464
new_velocity.y = -1.0;
65-
new_state = CharacterState::Walking;
65+
new_state = CharacterState::Running;
6666
}
6767

6868
// Favor facing left or right when two directions are pressed simultaneously
6969
// by checking left/right after up/down.
7070
if input_actions.is_active(Action::Left, player.id) {
7171
new_direction = Some(Direction::West);
7272
new_velocity.x = -1.0;
73-
new_state = CharacterState::Walking;
73+
new_state = CharacterState::Running;
7474
}
7575
if input_actions.is_active(Action::Right, player.id) {
7676
new_direction = Some(Direction::East);
7777
new_velocity.x = 1.0;
78-
new_state = CharacterState::Walking;
78+
new_state = CharacterState::Running;
7979
}
8080

8181
// If the user is pressing two directions at once, go diagonally with
@@ -84,14 +84,14 @@ pub fn handle_movement_input_system(
8484
new_velocity = new_velocity.normalize();
8585
}
8686

87-
if input_actions.is_active(Action::Run, player.id) {
88-
character.movement_speed = RUN_SPEED;
87+
if input_actions.is_active(Action::Walk, player.id) {
88+
character.movement_speed = WALK_SPEED;
8989
new_state = match new_state {
90-
CharacterState::Walking => CharacterState::Running,
91-
CharacterState::Idle | CharacterState::Running => new_state,
90+
CharacterState::Running => CharacterState::Walking,
91+
CharacterState::Idle | CharacterState::Walking => new_state,
9292
}
9393
} else {
94-
character.movement_speed = WALK_SPEED;
94+
character.movement_speed = RUN_SPEED;
9595
}
9696

9797
if let Some(direction) = new_direction {

src/core/input.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub enum Action {
2424
Left,
2525
Right,
2626

27-
Run,
27+
// Walk slowly, instead of running.
28+
Walk,
2829

2930
Accept,
3031
}
@@ -134,7 +135,7 @@ fn action_producer_system(
134135
input_action_set.activate(Action::Right, 0);
135136
}
136137
if keyboard_input.pressed(KeyCode::LShift) {
137-
input_action_set.activate(Action::Run, 0);
138+
input_action_set.activate(Action::Walk, 0);
138139
}
139140

140141
if keyboard_input.pressed(KeyCode::Up) {
@@ -150,7 +151,7 @@ fn action_producer_system(
150151
input_action_set.activate(Action::Right, 1);
151152
}
152153
if keyboard_input.pressed(KeyCode::RShift) {
153-
input_action_set.activate(Action::Run, 1);
154+
input_action_set.activate(Action::Walk, 1);
154155
}
155156

156157
for (i, gamepad) in gamepad_set.gamepads.iter().cloned().enumerate() {
@@ -196,7 +197,7 @@ fn action_producer_system(
196197
}
197198

198199
if button_inputs.pressed(GamepadButton(gamepad, GamepadButtonType::West)) {
199-
input_action_set.activate(Action::Run, player_num);
200+
input_action_set.activate(Action::Walk, player_num);
200201
}
201202
}
202203
}

0 commit comments

Comments
 (0)