Skip to content

Commit

Permalink
feat: change player2's control back to '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
vivi2393142 committed Feb 27, 2025
1 parent 05eefd7 commit 0436c71
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
6 changes: 2 additions & 4 deletions docs/src/classes/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ class Player extends Entity {
this.isPaused = pauseState;
}

keyPressed(event, entities, onDie) {
keyPressed(entities, onDie) {
if (this.status === Constants.EntityStatus.DIED) return;

const hitControl = this.controls[Constants.Control.HIT];

// when player press 'hit' while alive (not 'hit' or 'cooldown' status)
const hitControl = this.controls[Constants.Control.HIT];
if (
keyCode === hitControl.value &&
(hitControl.side === undefined || hitControl.side === event.location) &&
this.status === Constants.EntityStatus.ALIVE
) {
this.hit(entities, onDie);
Expand Down
6 changes: 1 addition & 5 deletions docs/src/config/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ const Settings = Object.freeze({
[Constants.Control.RIGHT]: { value: 39, name: 'Right Arrow' },
[Constants.Control.UP]: { value: 38, name: 'Up Arrow' },
[Constants.Control.DOWN]: { value: 40, name: 'Down Arrow' },
[Constants.Control.HIT]: {
value: 16,
name: 'Shift',
side: KeyboardEvent.DOM_KEY_LOCATION_RIGHT,
},
[Constants.Control.HIT]: { value: 191, name: '?' },
}),
}),
],
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Welcome extends BasePage {
this.introText = null;
this.checkiconP1 = null;
this.checkiconP2 = null;
this.introBox = { x: 20, y: 350, w: 430, h: 150 };
this.introBox = { x: 20, y: 350, w: 400, h: 150 };
this.delay = 0;
this.pauseGame = false;
}
Expand Down Expand Up @@ -243,7 +243,7 @@ class Welcome extends BasePage {
const p2 = new Text({
x: position.x + 10,
y: position.y + 80,
label: 'Player 2: [↑ ← ↓ →] Attack: [Shift]',
label: 'Player 2: [↑ ← ↓ →] Attack: [?]',
textAlign: [LEFT, CENTER],
textSize: Theme.text.fontSize.small,
color: Theme.palette.black,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/WelcomeIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WelcomeIntro extends BasePage {
text(
'Welcome to UNSTOPPABLE. \n' +
'Player 1: move with [W A S D], attack with [Q]\n' +
'Player 2: move with [↑ ← ↓ →], attack with [Shift]\n' +
'Player 2: move with [↑ ← ↓ →], attack with [?]\n' +
'to COME HERE area to start! Shall we?',
10,
height - 175,
Expand Down
16 changes: 6 additions & 10 deletions docs/src/pages/maps/BaseMapGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,15 @@ class BaseMapGame extends BasePage {
}

/** @override */
keyPressed(event) {
keyPressed() {
super.keyPressed();
this.players.forEach((player) => {
if (player.status === Constants.EntityStatus.DIED) return;
player.keyPressed(
event,
[...this.robots, ...this.players],
(diedEntity) => {
if (diedEntity.type === Constants.EntityType.PLAYER) {
this.alivePlayerCtn--;
}
},
);
player.keyPressed([...this.robots, ...this.players], (diedEntity) => {
if (diedEntity.type === Constants.EntityType.PLAYER) {
this.alivePlayerCtn--;
}
});
});
}
}

0 comments on commit 0436c71

Please sign in to comment.