# RCWeb Tanks

**Tanks** is a shared-screen, turn-based artillery game for RCWeb. One browser runs the battlefield at `/tanks/`, and every player uses `/tanks-c/` on a phone as their control deck.

![icon](pwa-512x512.png "Tank Game Icon")

The viewer owns the game state. Players join from their phones, take turns moving left or right on a scrolling generated landscape, set cannon angle and power, and fire gravity-driven shells. Shells carve craters into the terrain and apply splash damage to nearby tanks.

When only one tank remains, that player wins the round. The game then resets the landscape and respawns all joined players for the next battle.

## What The Display Shows

The display is the battlefield and referee. It shows the generated terrain, every tank, the current turn, wind, health, wins, and connection status. The camera scrolls across a wide landscape so the game can support many players spread across the map.

The display follows the active tank during aiming, follows the shell while it is in flight, then holds the impact point for two seconds so everyone can see the crater and damage before the next player is focused.

## How To Play

Open `/tanks/` on a shared display. Scan the QR code to open `/tanks-c/` in the same room. Each phone joins as one tank.

On your turn, move before firing, adjust angle and power, then fire the cannon. The camera follows the active tank and projectile across the wide battlefield.

## Turn Flow

Each active player gets a 45 second turn. During that turn the player may move left or right up to the movement allowance, adjust cannon angle, adjust firing power, and fire once. Firing ends the turn after the shell lands and damage is resolved.

If the timer expires before the player fires, the turn is skipped. If a player disconnects during their turn, their tank is disabled and the game advances to the next active tank.

## Terrain And Movement

Every round generates a new scrolling landscape. Tanks spawn across the terrain and are placed on safe, flattened areas where possible.

Movement follows the terrain. Tanks can drive left or right, but steep slopes block movement. Explosions carve craters into the ground, changing later movement and shot angles.

## Aiming, Wind, And Projectiles

Shells use gravity and wind, so shots follow arcing paths rather than straight lines. The current wind value is shown on the display and on each controller. The preview dots on the display help the active player estimate the path before firing.

The angle range is 0 to 180 degrees. Low angles fire flatter shots, higher angles make steeper arcs, and power controls launch speed.

## Damage And Winning

Explosions damage tanks inside the blast radius. Direct or near-direct hits do heavier damage, while tanks near the edge of the blast take less. Destroyed tanks remain visible but cannot act for the rest of that round.

When only one active tank remains, that player wins. The winner gets a win added to the scoreboard, the result is shown briefly, then a new terrain and fresh round are created after a short reset delay.

If all remaining tanks are destroyed at the same time, the round is a draw and resets.

## Many Players

Tanks is designed for many phones in one room. The display keeps a compact scoreboard and shows the active tank first. Tanks are spawned across the full width of the battlefield so larger groups have space to play.

Disconnected players are handled visibly. If a controller leaves before the round ends, its tank is marked disconnected, dimmed, skipped in the turn order, ignored by damage checks, and excluded from winner checks. If the controller reconnects with the same RCWeb client id, the tank can become active again.

## Setup Tips

Use `/tanks/` on the largest screen available. Landscape display gives the best shared-room experience, but the viewer also scales down for smaller screens. Players should open `/tanks-c/` in the same room, normally by scanning the QR code shown on the display.

The first player can join and wait, but the battle starts when at least two active tanks are connected.

## Powered By RCWeb

Tanks uses RCWeb's room-based WebSocket layer. Controllers send player intents such as join, move, aim, power, and fire to the viewer. The viewer validates those intents, owns the authoritative state, simulates terrain and projectiles, resolves damage, tracks turns, and sends status back to controllers.

The app uses vanilla HTML, CSS, and JavaScript with no external game engine.
