Skip to content

navaranjithsai/Space-Defender-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Space Defender

A classic arcade-style space shooter game built with vanilla JavaScript and HTML5 Canvas. Defend Earth from waves of alien invaders, dodge asteroids, and collect treasure in bonus rounds!

Game Version License HTML5 JavaScript Tailwind CSS

๐ŸŽฎ Play Now

Simply download the index.html file and open it in your web browser - no installation required!

๐Ÿ“– Table of Contents

โœจ Features

Core Gameplay

  • ๐ŸŽฏ Classic Arcade Action - Smooth 60 FPS gameplay with responsive controls
  • ๐Ÿ‘พ Multiple Enemy Types - Face off against different invader types with varying strengths
  • โ˜„๏ธ Dynamic Asteroids - Dodge falling space rocks that increase in frequency
  • ๐ŸŽจ Particle Effects - Explosive visual feedback for all interactions
  • ๐Ÿ”Š Retro Sound Effects - Web Audio API-generated sounds for authentic arcade feel

Progressive Difficulty System

  • ๐Ÿ“ˆ Level Progression - Difficulty increases with each level
  • โšก Speed Scaling - Enemies move and shoot faster as you advance
  • ๐ŸŒŸ Adaptive Spawning - Asteroid spawn rates increase over time

Bonus Features

  • ๐Ÿ’ฐ Bonus Levels - Special coin-collecting rounds every 3 levels
  • ๐Ÿช Shop System - Purchase power-ups between bonus rounds
  • ๐Ÿ›ก๏ธ Shield Protection - 10-second invincibility shield available for purchase
  • โค๏ธ Extra Lives - Buy additional lives with collected coins
  • โฑ๏ธ Timed Challenges - 10-second treasure chest collection rounds

Quality of Life

  • โธ๏ธ Pause Function - Pause anytime with 'P' key or pause button
  • ๐Ÿ”‡ Mute Option - Toggle sound effects on/off
  • ๐Ÿ“ฑ Mobile Support - Touch controls for mobile devices
  • ๐Ÿ–ฅ๏ธ Responsive Design - Adapts to any screen size

๐ŸŽฏ How to Play

  1. Objective: Survive waves of alien invaders while achieving the highest score possible
  2. Destroy Enemies: Shoot invaders and asteroids to earn points
  3. Avoid Damage: Dodge enemy bullets and falling asteroids
  4. Complete Levels: Clear all invaders to advance (earn +1 life per level!)
  5. Collect Coins: Every 3rd level is a bonus round - shoot treasure chests for coins
  6. Shop Wisely: Use coins to buy extra lives or shield protection
  7. Survive: Game ends when you run out of lives or invaders reach your position

๐ŸŽฎ Controls

Keyboard Controls

Key Action
โ† / A Move Left
โ†’ / D Move Right
SPACE Shoot
P Pause/Resume
Click Shoot (Mouse)

Mobile Controls

  • Touch buttons appear automatically on mobile devices
  • Left/Right arrows for movement
  • Fire button for shooting

๐Ÿ”ง Game Mechanics

Scoring System

  • Weak Invader: 10 points
  • Strong Invader: 20 points
  • Asteroid: 10 points
  • Level Completion: 100 points bonus
  • Bonus Life: +1 life for each completed level

Enemy Behavior

  • Invaders: Move horizontally and descend when reaching screen edges
  • Asteroids: Fall vertically with random rotation
  • Enemy Fire: Invaders shoot randomly with increasing frequency

Bonus Level Mechanics

  • Appears every 3 levels (3, 6, 9, etc.)
  • 10-second timer to collect treasure chests
  • Chests contain 10-40 coins randomly
  • Coins can only be spent immediately after bonus round

Shop Items

Item Cost Effect
Extra Life 50 ๐Ÿ’ฐ +1 life
Shield 100 ๐Ÿ’ฐ 10 seconds protection at level start

Difficulty Progression

  • Invader Speed: +0.2 per level
  • Shooting Rate: +0.0003 per level
  • Asteroid Spawn: +0.003 per level
  • Enemy Bullet Speed: +0.2 per level

๐Ÿ’พ Installation

Option 1: Direct Download

  1. Download the index.html file
  2. Open it in any modern web browser
  3. Start playing!

Option 2: Clone Repository

# Clone this repository
git clone [Space-Defender-Game](https://github.com/navaranjithsai/Space-Defender-Game.git)

# Navigate to the game directory
cd space-defender

# Open index.html in your browser
# On Mac:
open index.html
# On Windows:
start index.html
# On Linux:
xdg-open index.html

Option 3: Host on GitHub Pages

  1. Fork this repository
  2. Go to Settings โ†’ Pages
  3. Select "Deploy from branch" โ†’ main โ†’ root
  4. Your game will be available at https://yourusername.github.io/Space-Defender-Game/

๐Ÿ› ๏ธ Technologies Used

  • HTML5 Canvas - Game rendering and animation
  • Vanilla JavaScript - Game logic and mechanics (no frameworks!)
  • Tailwind CSS - UI styling via CDN
  • Web Audio API - Dynamic sound generation
  • CSS3 Animations - UI effects and transitions

๐ŸŒ Browser Compatibility

Browser Version Support
Chrome 90+ โœ… Full Support
Firefox 88+ โœ… Full Support
Safari 14+ โœ… Full Support
Edge 90+ โœ… Full Support
Opera 76+ โœ… Full Support
Mobile Chrome Latest โœ… Full Support
Mobile Safari Latest โœ… Full Support

๐ŸŽจ Screenshots

View Game Screenshots image

Main Menu

Start screen with game controls image

Gameplay

Active gameplay showing invaders, asteroids, and player ship image image

Bonus Level

Treasure chest collection round image

Shop Screen

Power-up purchase interface image

Shield Active

Player with protective bubble shield image

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Ideas for Contributions

  • ๐ŸŽฎ New power-ups (rapid fire, multi-shot, etc.)
  • ๐Ÿ‘พ Additional enemy types
  • ๐ŸŽจ Visual themes/skins
  • ๐ŸŽต Background music system
  • ๐Ÿ† High score leaderboard
  • ๐ŸŒ Different levels/backgrounds
  • ๐Ÿ’ฅ Boss battles
  • ๐Ÿš€ Player ship upgrades

๐Ÿ› Known Issues

  • Audio may not work on first interaction in some browsers or too beep sounds (requires user gesture)
  • Performance may vary on older mobile devices
  • Touch controls may overlap game area on very small screens

๐Ÿ“„ License

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

๐Ÿ‘จโ€๐Ÿ’ป Author

Navaranjith Sai

๐Ÿ™ Acknowledgments

  • Inspired by classic arcade games like Space Invaders and Galaga
  • Built as a learning project for HTML5 Canvas game development
  • Thanks to the open-source community for inspiration and resources

๐Ÿ“ˆ Future Roadmap

  • Local high score storage
  • Online leaderboards
  • Multiple difficulty modes
  • Boss battles every 10 levels
  • Power-up drops from destroyed enemies
  • Co-op multiplayer mode
  • Custom ship designs
  • Achievement system
  • Background music with mute option
  • Save game progress

๐ŸŽฎ Game Statistics

  • Total Lines of Code: ~1,200
  • Development Time: [2h]
  • File Size: ~45 KB (single file!)
  • No Dependencies: Pure vanilla JavaScript
  • Load Time: < 1 second

Made with โค๏ธ and HTML/JavaScript By Tech4File

โญ Star this repository if you enjoy the game!

Releases

No releases published

Packages

No packages published

Languages