{"id":29694123,"url":"https://github.com/s-rohan-kumar/space-invaders","last_synced_at":"2026-07-08T04:31:18.106Z","repository":{"id":301536918,"uuid":"1002662812","full_name":"S-Rohan-Kumar/Space-Invaders","owner":"S-Rohan-Kumar","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-27T10:44:08.000Z","size":30252,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-23T08:54:45.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/S-Rohan-Kumar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-15T23:54:59.000Z","updated_at":"2025-06-27T10:44:11.000Z","dependencies_parsed_at":"2025-06-27T11:52:56.853Z","dependency_job_id":null,"html_url":"https://github.com/S-Rohan-Kumar/Space-Invaders","commit_stats":null,"previous_names":["s-rohan-kumar/space-invaders"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/S-Rohan-Kumar/Space-Invaders","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-Rohan-Kumar%2FSpace-Invaders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-Rohan-Kumar%2FSpace-Invaders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-Rohan-Kumar%2FSpace-Invaders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-Rohan-Kumar%2FSpace-Invaders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/S-Rohan-Kumar","download_url":"https://codeload.github.com/S-Rohan-Kumar/Space-Invaders/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-Rohan-Kumar%2FSpace-Invaders/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281047794,"owners_count":26435124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-23T08:38:36.028Z","updated_at":"2025-10-26T01:37:19.666Z","avatar_url":"https://github.com/S-Rohan-Kumar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Space Invaders Game\n\nA classic Space Invaders arcade game implemented in Python using Pygame. Defend Earth by shooting down waves of alien invaders!\n\n## 🎮 Game Overview\n\nThis is a faithful recreation of the classic Space Invaders arcade game where you control a spaceship at the bottom of the screen, shooting at rows of descending alien enemies. The game features progressive difficulty, sound effects, and classic arcade gameplay.\n\n## 🚀 Features\n\n- **Classic Gameplay**: Move left/right and shoot at descending enemies\n- **Progressive Difficulty**: Each wave increases enemy count and speed\n- **Sound Effects**: Laser sounds, explosion effects, and background music\n- **Score System**: Earn points for each enemy destroyed\n- **Game Over Screen**: Restart or quit options when defeated\n- **Collision Detection**: Accurate sprite-based collision system\n- **Smooth Controls**: Responsive keyboard input with proper key handling\n\n## 🎯 Game Mechanics\n\n### Player Controls\n- **Left Arrow**: Move spaceship left\n- **Right Arrow**: Move spaceship right  \n- **Spacebar**: Fire laser bullets (up to 3 bullets on screen at once)\n\n### Game Rules\n- Destroy all enemies to advance to the next wave\n- Each wave spawns more enemies with increased speed\n- Game ends if enemies reach the bottom of the screen (y \u003e 440)\n- Score increases by 1 point per enemy destroyed\n\n### Progression System\n- **Starting Wave**: 4 enemies at speed 3\n- **Each New Wave**: +1 enemy, +0.5 speed increase\n- **Bullet Limit**: Maximum 3 bullets on screen simultaneously\n\n## 📁 Required Files\n\nThe game requires these asset files in the same directory:\n\n### Images\n- `player.png` - Player spaceship sprite\n- `enemy.png` - Enemy alien sprite  \n- `bullet.png` - Laser bullet sprite\n- `background.png` - Game background image\n- `ufo.png` - Game icon\n\n### Audio\n- `laser.wav` - Laser firing sound effect\n- `explosion.wav` - Enemy destruction sound\n- `background.mp3` - Background music (loops continuously)\n\n## 🛠️ Technical Implementation\n\n### Core Classes\n\n#### Spaceship Class\nA versatile sprite class that handles:\n- **Player Movement**: Boundary-constrained horizontal movement\n- **Enemy Movement**: Horizontal movement with direction changes and downward progression\n- **Bullet Movement**: Vertical upward movement for projectiles\n- **Collision Detection**: Rectangle-based collision system\n\n### Key Functions\n\n#### `create_enemies(no_of_enemies)`\n- Spawns enemies at random positions in the upper portion of the screen\n- Ensures enemies don't spawn outside screen boundaries\n\n#### `reset_game()`\n- Resets all game variables to initial state\n- Recreates player and enemy objects\n- Resets score and difficulty parameters\n\n#### `show_game_over()`\n- Displays game over screen with restart instructions\n- Shows restart (SPACE) and quit (ESC) options\n\n#### `iscollision(bullet, enemy)`\n- Handles sprite collision detection using Pygame's `colliderect()` method\n- Returns boolean for collision state\n\n#### `show_score(score)`\n- Renders and displays current score in top-left corner\n- Updates in real-time during gameplay\n\n## 🎨 Game States\n\n### Playing State\n- Player can move and shoot\n- Enemies move in formation\n- Collision detection active\n- Score tracking enabled\n\n### Game Over State\n- Movement disabled\n- Game over screen displayed\n- Restart/quit options available\n- All game objects frozen\n\n## 🔧 Configuration\n\n### Display Settings\n- **Screen Size**: 800x600 pixels\n- **Frame Rate**: 60 FPS\n- **Background Color**: Black (0,0,0)\n\n### Gameplay Parameters\n- **Player Speed**: 5 pixels per frame\n- **Initial Enemy Speed**: 3 pixels per frame\n- **Bullet Speed**: 7 pixels per frame\n- **Enemy Drop Distance**: 60 pixels when hitting screen edge\n- **Maximum Bullets**: 3 simultaneous bullets\n\n## 🎵 Audio System\n\nThe game features a complete audio system:\n- **Mixer Initialization**: Properly initialized before Pygame init\n- **Sound Effects**: Laser and explosion sounds with proper timing\n- **Background Music**: Continuous looping background music\n- **Resource Path Handling**: Compatible with PyInstaller for executable creation\n\n## 🚀 Installation \u0026 Setup\n\n### Requirements\n```bash\npip install pygame\n```\n\n### Running the Game\n1. Ensure all asset files are in the game directory\n2. Run the Python script:\n```bash\npython space_invaders.py\n```\n\n### Creating Executable\nThe code includes PyInstaller support with the `resource_path()` function for bundling assets into a standalone executable.\n\n## 🎮 Gameplay Tips\n\n- **Positioning**: Stay mobile to avoid enemy fire patterns\n- **Bullet Management**: Use all 3 bullet slots efficiently\n- **Wave Strategy**: Clear enemies systematically to prevent overwhelming situations\n- **Speed Increases**: Prepare for faster enemies in later waves\n\n## 🔄 Game Loop Structure\n\nThe main game loop handles:\n1. **Event Processing**: Keyboard input and window events\n2. **Game State Updates**: Player/enemy movement and collision detection\n3. **Rendering**: Drawing all sprites and UI elements\n4. **Display Updates**: Screen refresh at 60 FPS\n\n## 🏆 Scoring System\n\n- **Base Score**: 1 point per enemy destroyed\n- **Progressive Waves**: Unlimited waves with increasing difficulty\n- **High Score**: Displayed during gameplay in top-left corner\n\n## 🐛 Error Handling\n\nThe game includes proper error handling for:\n- **Boundary Checking**: Prevents sprites from moving off-screen\n- **List Management**: Safe removal of bullets and enemies during iteration\n- **Resource Loading**: Proper file path handling for assets\n\n## 📝 Code Structure\n\nThe codebase is organized with:\n- **Class-based Design**: Reusable Spaceship class for all moving objects\n- **Modular Functions**: Separate functions for different game aspects\n- **Clean Game Loop**: Well-structured main loop with clear state management\n- **Resource Management**: Proper asset loading and cleanup\n\nThis Space Invaders implementation provides a complete, playable game experience with all the classic elements that made the original arcade game a timeless classic!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-rohan-kumar%2Fspace-invaders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs-rohan-kumar%2Fspace-invaders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-rohan-kumar%2Fspace-invaders/lists"}