A retro-style arcade shooter built in Python with Pygame, procedural audio, and a MySQL-backed leaderboard system.
Space Invaders: Classic Arcade Edition is a desktop game that combines classic arcade gameplay with a modern structure. The project uses object-oriented design for the game logic, a dedicated database layer for persistence, and procedural audio to keep the package self-contained.
- Added MySQL connectivity through
mysql-connector-python. - Added automatic creation of the
space_invaders_dbdatabase and its schema. - Added
playersandscorestables plus theleaderboardview. - Added player CRUD operations, score saving, leaderboard loading, player history, and profile updates in
database.py. - Added
settings.pyandsettings.jsonfor persistent sound volume and mobile-control preferences. - Added
requirements.txtand a project-local.venvworkflow. - Preserved offline-safe gameplay when MySQL is unavailable.
- Reorganized game entities and managers, with procedural visuals, audio, power-ups, and boss encounters.
- Redesigned the login and registration screen with a responsive foreground panel and compact-window layout.
- Added complete keyboard focus navigation across callsign, password, login/register, and account-mode controls.
- Added Enter-key activation for the currently focused authentication action.
- Added four rotating boss sprites and periodic power-up drops during boss fights.
- Added a post-login pilot dashboard for gameplay, profile editing, statistics, match history, titles, leaderboard, and settings.
- Added 19 persistent achievements with lifetime and per-run progress on a keyboard-scrollable Titles page.
- Added Side Drones and a temporary 2x Score Multiplier power-up; drone drops use a lower random weight.
- Added persistent counters and safe startup migration for the new power-up session statistics.
- Wave-based gameplay with four rotating boss encounters
- Boss health is shown with a generic BOSS label; boss sprite names are not displayed
- Boss fights periodically spawn random power-ups during combat
- Responsive window resizing and adaptive UI
- Power-ups: shield, multishot, extra life, Side Drones, and a temporary 2x Score Multiplier
- Side Drones add two bullets to each player shot for 15 seconds and are less common than other power-ups
- Power-up effects and their remaining duration are shown in the gameplay HUD
- Procedural sound effects and background music
- Persistent player profiles and match history
- Login and registration with salted password hashes
- Post-login dashboard with profile editing, match history, statistics, and a titles page
- 19 persistent achievements covering lifetime milestones and per-run challenges
- Titles page shows locked/unlocked status and progress; browse with Up/Down, Page Up/Page Down, Home/End, or the mouse wheel
- Password visibility eye toggle on the login form
- Global leaderboard and audio settings screens
- Offline-safe gameplay when the database is unavailable
- Arrow Keys / A and D: Move left and right
- Spacebar: Shoot
- Escape: Pause or return to the menu
- F1: Open leaderboard
- F2: Open audio settings
- R: Restart after game over
- D: Return to the profile screen
- Tab / Shift+Tab: Move through profile-screen controls
- Q: Quit
main.py: entry point for the gamedatabase.py: database wrapper and schema managementconfig.py: database and gameplay configurationconstants.py: game-wide settings and helper functionsentities/: game entity classesplayer.py: player ship state, movement, and shootingenemy.py: enemy and boss behaviorbullet.py: player and enemy projectile classespowerup.py: power-up object logic and rendering
managers/: system manager modulesgame_manager.py: core game manager and event loopasset_manager.py: image loading and asset managementaudio_manager.py: procedural sound and music generationscreen_manager.py: profile, leaderboard, and settings screensui_manager.py: pause menu and UI widgetsachievement_manager.py: achievement definitions, progress tracking, and unlock persistence
assets/: game assetsimages/: game textures, sprites, and background assetssounds/: placeholder for sound resources
schema.sql: SQL schema referencetests/: regression tests for database, dashboard, bosses, achievements, and power-ups
- Windows, macOS, or Linux
- Python 3.11 or newer
- MySQL Server 8.x or compatible MySQL installation
- Git
The game can open without MySQL, but login, profiles, saved scores, achievement persistence, and leaderboards require a running MySQL server.
git clone https://github.com/YoursTrulyInarius/Space-Invader.git
cd Space-InvaderOpen the cloned folder in VS Code, then create the virtual environment from the project root.
PowerShell:
py -3.13 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txtIf PowerShell blocks script activation, run the project without activation:
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe main.pyThe .venv/ directory is ignored by Git and should not be committed.
-
Start MySQL Server.
-
Open config.py and set the MySQL host, username, password, and database if needed:
DB_CONFIG = { 'host': 'localhost', 'user': 'root', 'password': 'your_mysql_password', 'database': 'space_invaders_db' }
-
Run the setup script from the project root. It creates
space_invaders_db, the player, score, and achievement tables, indexes, andleaderboardautomatically when the configured MySQL user has database-creation permission:
python database_setup.pyWhen using the environment without activation, run .\.venv\Scripts\python.exe database_setup.py.
For advanced/manual SQL setup, run schema.sql in MySQL:
mysql -u root -p < schema.sqlschema.sql is intended as a clean rebuild script and drops the existing scores, players, and leaderboard objects. Back up production data before using it.
With .venv active, run:
python -c "from database import Database; db = Database(); player_id = db.create_player('test_player'); print('inserted player:', player_id); db.close()"The command should print the inserted player ID. Because usernames are unique, remove test_player or use another username before repeating the command.
settings.json stores local preferences:
sfx_volume: sound-effect volume from0.0to1.0music_volume: music volume from0.0to1.0mobile_controls: reserved toggle for mobile input support
The audio settings screen saves volume changes automatically. The file contains no database credentials.
From the project root, with .venv active:
python main.pyOn first launch, the database and tables are created automatically when MySQL is available. If MySQL is unavailable, the game remains playable without persistent data.
The project uses the following persistent structures:
players: stores usernames, password hashes, and cumulative player statsscores: stores per-session score, accuracy, duration, and counts for each power-up typeplayer_achievements: stores each player's unlocked achievementsplayer_achievement_progress: stores lifetime and per-run achievement metricsleaderboard: a view that returns the top scores for display
When upgrading an existing database, application startup adds missing password and power-up statistic columns. Existing player accounts created before login support must register a password before they can log in. Achievement tables are created automatically. schema.sql is a clean rebuild script that drops existing game tables and should only be used after backing up data.
The profile screen opens in Login mode. Enter a callsign and password, then press Enter or select LOGIN. Select CREATE ACCOUNT to register a new player; passwords must contain at least six characters. Select the eye icon inside the password field to show or hide the password while typing. Successful login opens the pilot dashboard rather than starting gameplay immediately. Choose PLAY to begin a run; use PROFILE to update your callsign, STATS to view lifetime totals and recent runs, or TITLES to browse all 19 achievements and their progress. The dashboard also provides the leaderboard, settings, and log-out actions.
Run all automated regression tests with the virtual-environment interpreter:
python -m unittest discover -s tests -p "test_*.py" -vThe tests use lightweight fakes for database behavior and do not require a live MySQL server. They cover the dashboard and achievements, boss sprite selection and fallback drawing, boss-fight power-up drops, power-up effects and statistics, and database schema/session behavior.
- Restructured workspace codebase directory layout to separate entities and managers
- Applied dynamic elliptical masking to hide dark border corners on enemy ship sprites
- Designed new procedural metallic cyan energy bolts for the player (with trailing plasma and sparks)
- Designed glowing red plasma artillery shells for the enemy (with pulsing halo and hot core)
- Relocated PNG game sprites to
assets/images/and updated loader references
- Added a pixelated solar system animation to the profile menu screen
- Polished main menu and button visuals with stronger scene presentation
- Added icons for leaderboard/settings menu buttons
- Preserved earlier modular refactor and audio improvements
- Modular game object refactor
- Refined enemy destruction audio
- Fixed boss rendering import issue
- OOP refactor for cleaner code
- Improved database initialization and startup reliability
- Added regression test coverage
- Leaderboard screen and audio settings screen
- UI and HUD fixes
- Improved sprite transparency and audio handling
- Boss fights and wave progression
- New visual assets and audio improvements
- Offline-safe database behavior
- Responsive window resizing
- New power-up icons and improved UI
- Core gameplay, audio synthesis, and MySQL integration