From 97348f884a570340e1ee244e544d2d0293aaa0d7 Mon Sep 17 00:00:00 2001 From: Niklas Haiden Date: Sun, 27 Sep 2026 23:11:40 +0200 Subject: [PATCH] feat(web): fill browser window and fix localhost loading Use a custom pygbag template: canvas uses the full window (gui_divider 1), black page background, and redirect localhost to 127.0.0.1 because the pygbag runtime otherwise fetches pygame from a local :8000 dev proxy and the game never starts. Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 4 +- README.md | 4 +- web/pygbag.tmpl | 443 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 449 insertions(+), 2 deletions(-) create mode 100644 web/pygbag.tmpl diff --git a/Dockerfile b/Dockerfile index fa055ab..a52d12b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,11 @@ RUN pip install --no-cache-dir pygbag==0.9.3 COPY main.py ./ COPY src/ ./src/ COPY assets/ ./assets/ +# Full-window canvas template; kept outside /app so it is not packed into the game. +COPY web/pygbag.tmpl /pygbag.tmpl # Do not publish the desktop leaderboard or developer files. RUN printf '[]\n' > src/highscore.json \ - && python -m pygbag --build --no_opt --disable-sound-format-error --title "Silent FH" . + && python -m pygbag --build --no_opt --disable-sound-format-error --title "Silent FH" --template /pygbag.tmpl . FROM nginxinc/nginx-unprivileged:1.28-alpine COPY --from=build /app/build/web/ /usr/share/nginx/html/ diff --git a/README.md b/README.md index 05bf477..5b09649 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,9 @@ docker build -t silent-fh:web . docker run -d --name silent-fh --restart unless-stopped -p 8080:8080 silent-fh:web ``` -Open **http://localhost:8080**. Allow the initial runtime download to finish, +Open **http://localhost:8080** (it redirects to `127.0.0.1`, because the +Pygbag runtime treats `localhost` as its dev server). The game scales to fill +the browser window while keeping its aspect ratio. Allow the initial runtime download to finish, click the game/name field, enter a name, and press Enter. A desktop browser with a keyboard is recommended; touch controls are not implemented. Reload the page to start again after quitting the game. diff --git a/web/pygbag.tmpl b/web/pygbag.tmpl new file mode 100644 index 0000000..7e750b4 --- /dev/null +++ b/web/pygbag.tmpl @@ -0,0 +1,443 @@ + + + {{cookiecutter.title}} + + + + + + + + + + + + + + + + + + + + +
+ +
Downloading...
+
+ +
+
+ + + + + + + + +
Loading, please wait ...
+ +
+ +
+ + + + + +
+ + + + +
+
+
+ + + + +