No description
Find a file
2026-01-07 23:36:12 +01:00
proxy first commit 2025-12-24 04:27:01 +01:00
server Build server for target architecture 2026-01-07 23:36:12 +01:00
web Add ghost piece highlight 2025-12-29 20:42:32 +01:00
.env Build server for target architecture 2026-01-07 23:36:12 +01:00
.gitignore Create docker compose override for development mode 2025-12-26 00:16:34 +01:00
docker-compose.override.yml.dist Create docker compose override for development mode 2025-12-26 00:16:34 +01:00
docker-compose.yml Build server for target architecture 2026-01-07 23:36:12 +01:00
README.md Add README.md 2025-12-27 00:03:40 +01:00

Tetris Lite (Browser)

Lightweight browser Tetris with ranking and online snapshots. Runs in a small container (e.g., Raspberry Pi) and supports async multiplayer via Redis.

Overview

  • Local gameplay in the browser (desktop and mobile).
  • Persistent arcade-style ranking.
  • Online player snapshots (right column).
  • Mobile mode: ranking before/after, gameplay + controls during.

Stack

  • Frontend: plain HTML/CSS/JS.
  • Backend: Go + Redis.
  • Proxy: Nginx (web + /api).

Run with Docker

docker compose up -d --build

Open:

  • http://localhost:${WEB_PORT} (see WEB_PORT in .env).

Frontend without rebuilds

Create a local override:

cp docker-compose.override.yml.dist docker-compose.override.yml
docker compose up -d

Edit files in web/ and refresh the browser.

Endpoints

  • POST /session -> create a session for a nick.
  • POST /snapshot -> send board + score.
  • DELETE /snapshot -> remove current snapshot.
  • GET /online -> list online players.
  • GET /leaderboard -> paginated ranking (limit, offset).
  • GET /rank -> rank for current session.

Configuration

Environment variables in .env:

  • WEB_PORT: proxy port (e.g., 9000).

Other envs in compose:

  • REDIS_ADDR: Redis host (default redis:6379)
  • SNAPSHOT_TTL_SECONDS: snapshot TTL (default 45)
  • SESSION_TTL_SECONDS: session TTL (default 86400)

Local dev (no Docker)

  1. Start Redis locally.
  2. Server:
cd server
go run .
  1. Web (any static server):
cd web
python3 -m http.server 5173

Notes

  • Ranking tie-break: score (desc) -> session timestamp (asc).
  • Snapshots are only considered online if updated recently.