Wrap name keyboard cursor around edges for left/right and up/down navigation

This commit is contained in:
Sterling Archer committed 2026-05-27 16:34:38 -07:00
1 parent ff9f235364
commit 5cc404efde
1 file changed
+15 -9
+15 -9
View File
@@ -403,10 +403,21 @@ class Game {
const keys = this._getNameKeys(); const keys = this._getNameKeys();
const total = keys.length; const total = keys.length;
let c = this._gpKeyCursor; let c = this._gpKeyCursor;
if (dir === 'right') c = Math.min(c + 1, total - 1); const row = Math.floor(c / COLS);
if (dir === 'left') c = Math.max(c - 1, 0); const col = c % COLS;
if (dir === 'down') c = Math.min(c + COLS, total - 1); const totalRows = Math.ceil(total / COLS);
if (dir === 'up') c = Math.max(c - COLS, 0); if (dir === 'right') {
c = (col + 1 >= COLS || c + 1 >= total) ? row * COLS : c + 1;
}
if (dir === 'left') {
c = (col - 1 < 0) ? Math.min(row * COLS + COLS - 1, total - 1) : c - 1;
}
if (dir === 'down') {
c = c + COLS >= total ? col : c + COLS;
}
if (dir === 'up') {
c = c - COLS < 0 ? Math.min((totalRows - 1) * COLS + col, total - 1) : c - COLS;
}
this._gpKeyCursor = c; this._gpKeyCursor = c;
this._renderNameCursor(); this._renderNameCursor();
SFX.select(); SFX.select();
@@ -1150,11 +1161,6 @@ class Game {
boot() { boot() {
this.show('boot'); this.show('boot');
this._showController(true); this._showController(true);
try {
const bootAudio = new Audio('./loading.mp3');
bootAudio.volume = 0.5;
bootAudio.play().catch(() => {});
} catch(e) {}
setTimeout(() => this.showTitle(), 1800); setTimeout(() => this.showTitle(), 1800);
} }