A 2D platformer shooter game built with vanilla JavaScript and HTML5 Canvas.
Ground Defender is a fast-paced arcade-style game where you defend your ground from falling enemies. Enemies spawn from the sky and fall with realistic gravity physics. Your mission: shoot them down before they reach you!
- 🎮 Three Difficulty Levels: Easy, Medium, and Hard
- 🏆 High Score System: Tracks your best performance with LocalStorage
- ⚡ Realistic Physics: Gravity simulation and collision detection
- 🎨 Clean Design: Minimalist UI with smooth animations
- ⏸️ Pause/Resume: Take a break anytime with ESC key
- 📱 Responsive: Optimized canvas rendering
- Arrow Left/Right (← →): Move player
- Space: Shoot
- ESC: Pause game
- Choose your difficulty level
- Enemies fall from the sky with gravity
- Shoot them before they hit you or the ground
- Survive as long as possible and beat your high score!
- One hit = Game Over
Try it now in your browser - no installation required!
- A modern web browser (Chrome, Firefox, Safari, Edge)
- Optional: Local web server
- Clone the repository
git clone https://github.com/sepehrhajati/Ground-Defender.git
cd Ground-Defender- Open with a local server (recommended)
Using Python 3
python -m http.server 8000Using Node.js
npx http-server
Or simply open index.html in your browser- Navigate to
http://localhost:8000in your browser
- HTML5 - Structure and Canvas element
- CSS3 - Styling and animations
- JavaScript (ES6+) - Game logic and OOP architecture
- Canvas API - 2D graphics rendering
- LocalStorage API - Score persistence
The game follows Object-Oriented Programming principles with a clean class hierarchy:
- GameObject (Abstract base class)
- Player
- Enemy
- Bullet
- GameEngine (Manages game loop and state)
- InputHandler (Processes keyboard events)
- ScoreManager (Handles scoring and persistence)
Select your difficulty and start your defense!
Fast-paced shooting and dodging mechanics.
Track your progress and beat your high score!
- Power-ups and special weapons
- Multiple enemy types with unique behaviors
- Boss battles
- Sound effects and background music
- Online leaderboard
- Mobile touch controls
- Multiplayer mode
- Efficient Rendering: Optimized Canvas API usage for smooth 60 FPS gameplay
- Delta Time: Frame-rate independent physics calculations
- Collision Detection: AABB (Axis-Aligned Bounding Box) algorithm
- State Management: Clean separation of game states (Menu, Running, Paused, Game Over)
- Object Pooling: Memory-efficient entity management
- Modular Design: Separated concerns with dedicated classes
None at the moment! If you find any bugs, please open an issue.
This project is licensed under the MIT License - see the LICENSE file for details.
Sepehr Hajati
- GitHub: @sepehrhajati
- Built with passion for classic arcade games
- Inspired by Space Invaders and similar retro shooters
- Special thanks to the open-source community
Enjoy the game! 🎮
If you like this project, please give it a ⭐ on GitHub
Made with ❤️ and JavaScript