TripGeo Blog

News, updates and map curiosities

All posts

Multiplayer Battleships: A Classic Naval Battle in Your Browser

Multiplayer Battleships: A Classic Naval Battle in Your Browser

How to Play

Battleships is a timeless strategy game where two players face off in an intense naval battle. The objective is simple: be the first to sink all of your opponent's ships!

Each player commands a fleet of five ships of varying sizes:

  • Carrier (5 squares)
  • Battleship (4 squares)
  • Two Cruisers (3 squares each)
  • Destroyer (2 squares)

Game Flow

1. Join a Room: Create or join a game room with a unique room ID. Share the link with a friend to invite them to battle.

2. Deploy Your Fleet: Strategically place your ships on a 10x10 grid. Ships cannot touch each other, even diagonally. Choose your positions wisely - they could mean the difference between victory and defeat!

3. Take Turns Firing: Players alternate taking shots at their opponent's grid. Click on enemy waters to fire. You'll see if you hit (💥), missed (💧), or sunk an entire ship (💀).

4. Victory Conditions: The first player to sink all five of their opponent's ships wins the battle. If your opponent disconnects or leaves, you win by forfeit!

Features

  • Real-time multiplayer gameplay
  • Live chat during gameplay and in the lobby
  • Visual feedback with emojis for hits, misses, and sunken ships
  • Progress tracking during ship deployment
  • Post-game statistics showing fleet damage percentages
  • Instant rematch capability - just return to lobby and ready up again!

Technical Implementation

This Battleships game was developed as a proof-of-concept project with assistance from Claude AI. The primary goal was to create a robust foundation for peer-to-peer communication that could be adapted for future multiplayer projects.

Technology Stack

The game utilizes WebRTC (Web Real-Time Communication) for direct browser-to-browser connections, enabling low-latency gameplay without routing all traffic through a central server. SignalR handles the initial connection negotiation and room management, creating a hybrid architecture that combines the best of both technologies.

Key technical features include:

  • WebRTC data channels for real-time game state synchronization
  • SignalR hub connections for lobby management and initial peer discovery
  • Custom protocol for game events (shots, hits, deployment progress, etc.)
  • Automatic handling of connection states and player disconnections
  • Turn-based game logic with state validation

The codebase is structured to be modular and reusable. The WebRTC and SignalR communication layers are separated from game logic, making it straightforward to adapt this foundation for other multiplayer projects such as card games, board games, or collaborative applications.

Future Applications

The peer-to-peer communication framework developed for Battleships can be extended to support:

  • Other turn-based strategy games
  • Real-time collaborative tools
  • Video or audio chat applications
  • File sharing between browsers
  • Multiplayer educational games

Play Now

Ready to command your fleet? Launch Battleships and challenge a friend to naval combat!

The game requires two players to start. Simply create a room, share the link with your opponent, and prepare for battle!

More from the blog

Hogs of Duty: When Pigs Fly, We Fly with Them

Hogs of Duty: When Pigs Fly, We Fly with Them

A comedy first-person shooter where every soldier is a pig. Train under Sgt. Major McSwill at FOB Muddy Waters, then take back the suburbs of Porkville Heights from the Sowviets in two missions played completely straight. Free in your browser.

Snow Globe Streets: Put Any Street in a Snow Globe

Snow Globe Streets: Put Any Street in a Snow Globe

Famous places and any address in the world, built in real 3D from Google imagery inside a snow globe you can shake, zoom into and walk around. Choose snow, blossom or fireworks, write a message and send it as a link that plays on any phone.

Constructor Cats: Build a Town Run by Cats

Constructor Cats: Build a Town Run by Cats

Two cats and a tent grow into a whole town. Constructor Cats is a cosy city builder in your browser where every brick is laid by a cat in a hard hat, with 64 cats, the Yarn Ball Cup, a Be the Cat mode and a Christmas Card Creator.

ATC Kaos: Sit Back, Relax, the Computer Has It Handled

ATC Kaos: Sit Back, Relax, the Computer Has It Handled

Run the tower at Bedlam International on the day a brand-new AI called ORVILLE takes over. It's always right, until it isn't. A comedy air traffic control game in your browser, with zeppelins, flying saucers and a By the Book mode.

Atlantis: The Day the World Turned Over

Atlantis: The Day the World Turned Over

Somebody pressed the button. Now every ocean has drained into the continents, Everest is an abyss and the Challenger Deep is the roof of the world. Take the submersible Nereid out to explore the Earth turned upside down.

Doodle Flyer: The Worst Drawn Air Battles of World War II

Doodle Flyer: The Worst Drawn Air Battles of World War II

1940. The skies are on fire. Doodle Flyer is WW2 air combat in a hand-drawn style, right in your browser, with ten missions, five aircraft and a one-minute trailer straight from the game engine.

All 43 posts