Skip to content

Commit

Permalink
Add jump throw bind
Browse files Browse the repository at this point in the history
  • Loading branch information
solcloud committed Mar 21, 2024
1 parent 94072f1 commit 5e0ec6d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions www/assets/js/Enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ const Action = {
MOVE_BACK: 'back',
MOVE_RIGHT: 'right',
JUMP: 'jump',
JUMP_THROW: 'jump_throw',
CROUCH: 'crouch',
WALK: 'walk',
RELOAD: 'reload',
Expand Down
8 changes: 7 additions & 1 deletion www/assets/js/PlayerAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Action, InventorySlot} from "./Enums.js";
import {Action, GrenadeSlots, InventorySlot} from "./Enums.js";

export class PlayerAction {
#game
Expand Down Expand Up @@ -70,6 +70,12 @@ export class PlayerAction {
this.#actionCallback[Action.MOVE_RIGHT] = (enabled) => this.#states.moveRight = enabled
this.#actionCallback[Action.USE] = (enabled) => this.#states.use = enabled
this.#actionCallback[Action.JUMP] = (enabled) => enabled && (this.#states.jumping = true)
this.#actionCallback[Action.JUMP_THROW] = (enabled) => {
if (enabled && GrenadeSlots.includes(game.playerMe.getEquippedSlotId())) {
this.#states.jumping = true
this.attack(game.getPlayerMeRotation())
}
}
this.#actionCallback[Action.CROUCH] = (enabled) => enabled ? this.#states.crouching = true : this.#states.standing = true
this.#actionCallback[Action.WALK] = (enabled) => enabled ? this.#states.shifting = true : this.#states.running = true
this.#actionCallback[Action.DROP] = (enabled) => enabled && (this.#states.drop = true)
Expand Down
1 change: 1 addition & 0 deletions www/assets/js/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class Setting {
'KeyV': Action.EQUIP_KNIFE,
'KeyT': Action.DROP_BOMB,
'KeyH': Action.SWITCH_HANDS,
'KeyJ': Action.JUMP_THROW,
'Digit1': Action.EQUIP_PRIMARY,
'Digit2': Action.EQUIP_SECONDARY,
'Digit3': Action.EQUIP_KNIFE,
Expand Down

0 comments on commit 5e0ec6d

Please sign in to comment.