Skip to content

dducnv/battleship

Repository files navigation

⚓ Battleship — P2P Multiplayer Naval Combat

A modern, real-time, peer-to-peer multiplayer Battleship game built with Next.js 15, TypeScript, and Supabase Realtime. Experience the classic naval warfare with a sleek dark-navy interface, immersive sound effects, and zero-latency P2P synchronization.

Next.js TypeScript Supabase Zustand


🚀 Key Features

📡 Real-time P2P Multiplayer

No custom backend server required! The game leverages Supabase Realtime Channels (Presence & Broadcast) to synchronize game states directly between browser peers.

🎮 Dynamic Gameplay Logic

  • Standard Rules: All 5 classic ships (Carrier, Battleship, Cruiser, Submarine, Destroyer).
  • "Hit-Again" Rule: Keep your turn as long as you land a hit on the enemy fleet.
  • Ready Sync: Robust P2P handshake ensures both players are ready before battle begins.

🚢 Advanced Ship Placement

  • Interactive drag-and-drop/click placement.
  • Seamless rotation support (press 'R').
  • Auto-placement algorithm for quick deployment.

🔊 Immersive Audio Experience

  • Dynamic Battle Theme: Music that intensifies when the combat phase begins.
  • Cinematic SFX: High-quality sounds for firing shots, explosions on hits, and turn transitions.
  • Global Volume Control: Adjust your audio experience directly from the status bar.

🎨 Modern UI/UX

  • Dark Navy Aesthetics: A clean, military-inspired interface with glassmorphism effects.
  • Responsive Design: Fully playable on desktops, tablets, and mobile devices.
  • Victory/Defeat States: Clear visual and audio feedback upon game conclusion.

🛠 Tech Stack


🏁 Getting Started

1. Clone the repository

git clone https://github.com/your-username/battleship.git
cd battleship

2. Install dependencies

npm install

3. Environment Setup

Create a .env.local file in the root directory and add your Supabase credentials:

NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key

4. Run Development Server

npm run dev

Open http://localhost:3000 in your browser. To test the multiplayer, open another window in Incognito mode or a different browser.


📜 Credits & Assets

Special thanks to the creators on OpenGameArt.org for the amazing assets:


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❤️ for the Naval Combat fans.

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors