This is a visually engaging and advanced Battleship Game built using Python and Pygame, designed to simulate the classic naval war strategy game — with a modern twist. The game features a level-based grid system (Easy, Hard), interactive UI, and an AI opponent.
It showcases turn-based gameplay, grid-based logic, and real-time feedback using hits, misses, and dynamic rendering. This project also demonstrates strong structuring in code, file organization, and scalable game logic.
Choose between Easy or Hard, each scaling the challenge and grid dimensions.
Player ships are represented with real ship images and can be placed intuitively on the grid by dragging and dropping.
The AI randomly positions its ships on its side of the board with balanced distribution logic.
Players take alternating turns firing at the opponent’s grid, with visual feedback for hits and misses.
Each ship's gun visually rotates in real-time to follow the player's mouse cursor, enhancing immersion.
Every action is accompanied by realistic sound effects—explosions for hits, splashes for misses, and gunfire on attacks.
A tactical radar can be activated to sweep and reveal glimpses of hidden enemy ships on the board.
The game automatically detects when all ships of a player are sunk, declaring the winner.
Includes grid labels, animations, and action prompts for a polished user experience.
Programming Language: Python 3.X
Libraries: Pygame ( for graphics, events, rendering )
Core Concepts:
⊡ Event-driven programming
⊡ Collision handling (mouse clicks & grid mapping)
⊡ Turn-based state machine logic
⊡ AI logic with random attack generation
⊡ Dynamic GUI rendering using Pygame
🔧 Setup:
1. Make sure Python 3.x is installed.
2. Install Pygame if not already:
pip install pygame
1. Copy the source code from the file : src.py
2. Paste the code on a Python file & save it as ' Battleship.py '.
🎮 Controls:
1. Placing Ships:
- Drag and drop ships on Left board: or click on ' Randomize ' to position them.
- Click on ' Deploy '.
2. Game Play:
- Click on grid boxes on Right board to fire shots on Opponent's ships.
- Use ' Radar ' to scan enemy waters and locate the ship.
I’d love to hear from you!
If you encounter any Bugs, Issues, or have Suggestions for improvements.
If you like ❤️ this project, give it a ⭐ (Top right of page) and share it with friends!








