feat: WASD controls for minigame · feildmaster/UnderScript@4d4949b · GitHub
Skip to content

Commit 4d4949b

Browse files
committed
feat: WASD controls for minigame
1 parent 7e2de84 commit 4d4949b

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

changelog.md

Lines changed: 3 additions & 0 deletions

src/base/lobby/noMinigame.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
wrap(function minigames() {
22
const setting = settings.register({
3-
name: 'Disable mini-games',
3+
name: 'Disable',
44
key: 'underscript.minigames.disabled',
55
page: 'Lobby',
66
refresh: onPage('Play'),
7+
category: 'Minigames',
78
});
89

910
onPage('Play', () => {

src/base/lobby/wasd.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
wrap(() => {
2+
const setting = settings.register({
3+
name: 'Use WASD',
4+
key: 'underscript.minigames.wasd',
5+
page: 'Lobby',
6+
category: 'Minigames',
7+
});
8+
9+
function onCreate() {
10+
this.super();
11+
if (!setting.value()) return;
12+
const game = global('game');
13+
const KeyCode = global('Phaser').KeyCode;
14+
const cursors = game.input.keyboard.addKeys({ up: KeyCode.W, down: KeyCode.S, left: KeyCode.A, right: KeyCode.D });
15+
globalSet('cursors', cursors);
16+
}
17+
18+
onPage('Play', () => {
19+
let bound = false;
20+
eventManager.on('pre:getJoinedQueue', () => {
21+
if (bound) return;
22+
const create = global('create', { throws: false });
23+
if (!create) return;
24+
globalSet('create', onCreate);
25+
bound = true;
26+
});
27+
});
28+
});

src/hooks/play.js

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)