Skip to content

tagler/dave-ball

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DAVE BALL Logo

🎯 Capture territory Β· πŸ’Ž Grab power-ups Β· ⚑ Dodge the balls!

tests license python docker azure status built with


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.

Start Screen

Gameplay


πŸ•ΉοΈ How to Play

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

Gameplay

Drawing Lines & Dodging Balls

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!

Drawing Lines

Power-ups, Obstacles & Shapes

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.

Power-ups and Shapes

Advanced Levels

As you progress, more balls spawn, speeds increase, and multiple obstacles crowd the arena. Strategy matters β€” plan your lines carefully!

Advanced Gameplay


✨ Features

  • 🎯 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

πŸ”₯ Power-ups

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

⚠️ Hazards

Icon Name Effect
☠️ Skull Lose a life
πŸ„ Grow Makes balls larger and harder to dodge

πŸ’ Bonus Fruits

Fruit Points
πŸ’ Cherry 100
🍊 Orange 200
🍎 Apple 300
πŸ‡ Grape 500
πŸ“ Strawberry 1,000

πŸš€ Quick Start

Play Now

The game is hosted on Azure β€” run azd env get-values for the live URL after deploying, or run locally:

Docker (local)

docker-compose up

Open http://localhost:8080 and click "Click to Play".

Manual Setup

# 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:8080

πŸ—οΈ Architecture

Server-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)

Key Backend Modules

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

πŸ§ͺ Testing

# 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 -v

229+ 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


πŸ“‚ Project Structure

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

πŸ“– How to Play Screen

How to Play


🀝 Contributing

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

About

Dave Ball - A territory-capture arcade game

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors