Skip to content

Commit 362eefa

Browse files
committed
Bump version to 1.4.2 and update dependencies for improved stability
1 parent 90898c3 commit 362eefa

3 files changed

Lines changed: 92 additions & 72 deletions

File tree

app/static/script.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const start_audio = new Audio("static/sounds/start.mp3");
1111

1212
document.body.style.cursor = 'none';
1313

14+
let gameStartTimeout;
15+
const GAME_START_COOLDOWN = 1000; // 1 second cooldown between game starts
16+
1417
document.addEventListener("keydown", async (evt) => {
1518
if (games.length === 0) return;
1619

@@ -31,18 +34,33 @@ document.addEventListener("keydown", async (evt) => {
3134
}
3235

3336
if (evt.key === "Enter") {
37+
if (gameStartTimeout) return; // Ignore if within cooldown period
38+
39+
gameStartTimeout = true;
3440
await play_audio(start_audio);
3541
const url = games[index].getAttribute("game-url");
3642
if (url) {
3743
window.open(url, '_blank');
3844
}
45+
46+
// Reset cooldown after delay
47+
setTimeout(() => {
48+
gameStartTimeout = false;
49+
}, GAME_START_COOLDOWN);
3950
}
4051
});
4152

4253
function play_audio(audio) {
4354
return new Promise(res => {
44-
audio.play().catch(() => res()); // Handle cases where play is interrupted
45-
audio.onended = res;
55+
const onended = () => {
56+
audio.removeEventListener('ended', onended);
57+
res();
58+
};
59+
audio.addEventListener('ended', onended);
60+
audio.play().catch(() => {
61+
audio.removeEventListener('ended', onended);
62+
res();
63+
});
4664
});
4765
}
4866

@@ -77,28 +95,35 @@ function gameLoop() {
7795

7896
// --- Axis (Stick) Navigation ---
7997
const axisThreshold = 0.7;
80-
const leftStickX = gamepad.axes[0];
98+
const leftStickX = gamepad.axes[0] || 0;
99+
const lastLeftStickX = lastGamepadState.axes[0] || 0;
81100

82101
// Left Stick Right
83-
if (leftStickX > axisThreshold && lastGamepadState.axes[0] < axisThreshold) {
102+
if (leftStickX > axisThreshold && lastLeftStickX < axisThreshold) {
84103
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'ArrowRight'}));
85104
}
86105
// Left Stick Left
87-
if (leftStickX < -axisThreshold && lastGamepadState.axes[0] > -axisThreshold) {
106+
if (leftStickX < -axisThreshold && lastLeftStickX > -axisThreshold) {
88107
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'ArrowLeft'}));
89108
}
90109

91110
// --- Button Navigation ---
92111
// D-Pad Right (Button 15)
93-
if (gamepad.buttons[15] && !lastGamepadState.buttons[15]?.pressed) {
112+
const btn15 = gamepad.buttons[15];
113+
const lastBtn15 = lastGamepadState.buttons[15];
114+
if (btn15?.pressed && !lastBtn15?.pressed) {
94115
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'ArrowRight'}));
95116
}
96117
// D-Pad Left (Button 14)
97-
if (gamepad.buttons[14] && !lastGamepadState.buttons[14]?.pressed) {
118+
const btn14 = gamepad.buttons[14];
119+
const lastBtn14 = lastGamepadState.buttons[14];
120+
if (btn14?.pressed && !lastBtn14?.pressed) {
98121
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'ArrowLeft'}));
99122
}
100123
// A Button (or X on PS, Button 0) for Enter
101-
if (gamepad.buttons[0] && !lastGamepadState.buttons[0]?.pressed) {
124+
const btn0 = gamepad.buttons[0];
125+
const lastBtn0 = lastGamepadState.buttons[0];
126+
if (btn0?.pressed && !lastBtn0?.pressed) {
102127
document.dispatchEvent(new KeyboardEvent('keydown', {'key': 'Enter'}));
103128
}
104129

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "GameGrid"
3-
version = "1.4.1"
3+
version = "1.4.2"
44
description = "A flask wrapper for your WebGL games"
55
readme = "README.md"
66
requires-python = ">=3.10,<3.13"
@@ -9,19 +9,19 @@ license = "MIT"
99
keywords = ["flask", "webgl", "arcade", "games"]
1010

1111
dependencies = [
12-
"uv",
12+
"uv==0.12.9",
1313
"blinker==1.9.0",
14-
"click==8.3.1",
14+
"click==8.5.0",
1515
"colorama==0.4.6",
16-
"Flask==3.1.2",
17-
"Flask-Cors==6.0.2",
16+
"flask==3.1.3",
17+
"flask-cors==6.0.5",
1818
"itsdangerous==2.2.0",
1919
"Jinja2==3.1.6",
2020
"loguru==0.7.3",
2121
"MarkupSafe==3.0.3",
22-
"gunicorn==23.0.0",
22+
"gunicorn==26.2.0",
2323
"PyYAML==6.0.3",
24-
"Werkzeug==3.1.5",
24+
"werkzeug==3.1.8",
2525
"win32_setctime==1.2.0",
2626
]
2727

0 commit comments

Comments
 (0)