An arcade territory-claiming game built with Python and HTML5 Canvas. Draw boundary lines to partition the arena, dodge bouncing balls, and collect 24 different power-ups across endless levels.
| Control | Action |
|---|---|
| Left-click | Draw a boundary line from your cursor |
| Right-click / Space | Toggle line direction (horizontal β vertical) |
| ESC | Pause / resume |
- Lines grow from your click point toward the nearest wall or existing boundary
- If a ball hits your growing line, you lose a life!
- Completed lines create new walls β enclose regions without balls to fill them
- Capture power-ups and fruits by boxing them in with completed lines
- Fill 70% of the area to complete each level
Click to draw boundary lines that grow toward the nearest wall. Complete lines to claim territory β but don't let a ball hit your growing line!
Higher levels feature obstacle shapes (star, diamond, square, circle, octagon) and power-ups scattered across the arena. Enclose them with your lines to capture their effects.
As you progress, more balls spawn, speeds increase, and multiple obstacles crowd the arena. Strategy matters β plan your lines carefully!
- π― 24 Power-ups β Fire, Acid, Snake, Nuke, Shield, Freeze, Portal, and more
- π 5 Fruit types β Cherry, Orange, Apple, Grape, Strawberry for bonus points
- π¨ 5 Color themes β Default, Neon, Retro, Ocean, Lava
- π΅ Procedural audio β 8-bit music and sound effects via Web Audio API (zero audio files!)
- π High score leaderboard β Compete for the top 10 with 3-letter initials
- π Endless level progression β More balls and faster speeds each level
- π· Obstacle shapes β Circle, square, triangle, diamond, star, octagon
- ποΈ 3 Speed settings β Slow, Normal, Fast
- βοΈ Ball physics β Ball-ball collisions, fission, and rare tunneling
- β¨ Visual effects β Rainbow lines, screen shake, fireworks, particle systems
Capture power-ups by enclosing them with completed boundary lines.
| Icon | Name | Effect |
|---|---|---|
| β€οΈ | Heart | +1 extra life |
| β±οΈ | Clock | Slow all balls 50% for 10s |
| π‘οΈ | Shield | Next line is indestructible |
| β‘ | Lightning | Next line grows at 5Γ speed |
| π£ | Bomb | Removes one random ball |
| π§ | Freeze | Freeze all balls for 5s |
| π | Shrink | Shrink all balls |
| π₯ | Fire | Next line burns balls on contact |
| π§ͺ | Acid | Spawn acid pools that dissolve balls |
| β’οΈ | Nuke | Blast radius destroys nearby balls |
| π | Snake | Snake hunts and eats balls |
| π§² | Magnet | Pull balls toward your cursor |
| β | Anchor | Stop all balls permanently (rare!) |
| π | Portal | Linked portals that teleport balls |
| π³οΈ | Sinkhole | Gravity well that pulls in balls |
| πΈοΈ | Web | Sticky slow zones |
| γ°οΈ | Wave | Balls move in wave patterns |
| π | Fusion | Balls merge on collision |
| βοΈ | Fission | Ball collisions create new balls |
| π¬ | Candy | Bonus points |
| π² | Mystery | Random power-up (slot machine reveal!) |
| π² | Jackpot | Ultra-rare instant level clear |
| Icon | Name | Effect |
|---|---|---|
| β οΈ | Skull | Lose a life |
| π | Grow | Makes balls larger and harder to dodge |
| Fruit | Points |
|---|---|
| π Cherry | 100 |
| π Orange | 200 |
| π Apple | 300 |
| π Grape | 500 |
| π Strawberry | 1,000 |
The game is hosted on Azure β run azd env get-values for the live URL after deploying, or run locally:
docker-compose upOpen http://localhost:8080 and click "Click to Play".
# Backend (Python 3.11+)
cd backend
pip install -r requirements.txt
python app.py
# β runs on http://localhost:5000
# Frontend (any static server)
cd frontend
python -m http.server 8080
# β runs on http://localhost:8080Server-authoritative model β all game logic runs on the Python backend. The frontend is a pure renderer with no game state.
βββββββββββββββββ WebSocket (Socket.IO) βββββββββββββββββββ
β Frontend β ββββββββββββββββββββββββΊ β Backend β
β HTML5 Canvas β input events β Python 3.11 β
β 60fps render β game state @ 30Hz β Flask-SocketIO β
βββββββββββββββββ βββββββββββββββββββ
| Layer | Technology |
|---|---|
| Backend | Python 3.11, Flask, Flask-SocketIO, eventlet |
| Frontend | HTML5 Canvas, vanilla JavaScript (no framework) |
| Communication | WebSocket (Socket.IO) |
| Containers | Docker, Docker Compose |
| Hosting | Azure Container Apps (East US) |
| Testing | pytest (229+ tests) |
| Module | Purpose |
|---|---|
game_state.py |
Core engine β balls, lines, territory, power-ups, scoring |
physics.py |
Ball class, wall/line/ball-ball collision detection |
territory.py |
BFS flood fill for enclosed region detection |
config.py |
All tunable game constants |
app.py |
Flask-SocketIO server, game loop, event handlers |
# Full suite
python -m pytest tests/ -v
# By marker
python -m pytest -m physics -v
python -m pytest -m territory -v
python -m pytest -m powerups -v
python -m pytest -m scoring -v229+ tests covering physics, territory detection, power-ups, scoring, obstacles, snake behavior, and gameplay flows.
Available markers: physics Β· territory Β· line_growth Β· powerups Β· scoring Β· snake Β· obstacles Β· gameplay Β· coverage Β· slow
dave-ball/
βββ backend/
β βββ app.py # Flask-SocketIO server & game loop
β βββ config.py # Game constants & balance tuning
β βββ game_state.py # Core game engine
β βββ physics.py # Ball physics & collision detection
β βββ territory.py # BFS flood fill & region detection
β βββ highscores.py # High score persistence (JSON)
β βββ Dockerfile.prod # Production backend container
β βββ requirements.txt
βββ frontend/
β βββ index.html # Game page with all UI overlays
β βββ css/styles.css # Styling & themes
β βββ js/
β β βββ renderer.js # Canvas drawing & visual effects
β β βββ input.js # Mouse & keyboard event handling
β β βββ interpolation.js # Smooth ball position interpolation
β β βββ sound.js # Procedural audio (Web Audio API)
β β βββ main.js # Entry point & Socket.IO setup
β βββ nginx.conf # nginx config for local Docker
β βββ nginx.aca.conf # nginx config template for Azure (envsubst)
β βββ Dockerfile.aca # Azure Container Apps frontend container
β βββ Dockerfile.prod # Local production frontend container
βββ infra/
β βββ main.bicep # Azure infrastructure entry point
β βββ main.parameters.json
β βββ modules/
β βββ resources.bicep # ACR, Container Apps, Storage, Log Analytics
βββ tests/ # 229+ pytest tests
βββ azure.yaml # Azure Developer CLI service config
βββ docker-compose.yml # Local development
βββ docker-compose.prod.yml # Local production
βββ pyproject.toml
See CONTRIBUTING.md for development setup, code style guidelines, and PR checklist.
Built with Python π and HTML5 Canvas π¨ Β· Powered by GitHub Copilot CLI and Squad






