A browser-based game that combines Space Invaders with Tetris elements and Firebase integration for high score tracking.
This game is hosted on GitHub Pages. You can play it directly in your browser at: https://adrev.github.io/SpaceTetris/
This game uses Firebase for storing high scores. To set up your own Firebase project:
- Create a Firebase project at https://console.firebase.google.com/
- Set up a Realtime Database in your project
- Copy your Firebase configuration from the Firebase console
- Open the
config.jsfile and replace the placeholder values with your actual Firebase credentials:
firebaseConfig.setAttribute('data-api-key', 'YOUR_API_KEY');
firebaseConfig.setAttribute('data-auth-domain', 'YOUR_PROJECT_ID.firebaseapp.com');
firebaseConfig.setAttribute('data-project-id', 'YOUR_PROJECT_ID');
firebaseConfig.setAttribute('data-storage-bucket', 'YOUR_PROJECT_ID.appspot.com');
firebaseConfig.setAttribute('data-messaging-sender-id', 'YOUR_MESSAGING_SENDER_ID');
firebaseConfig.setAttribute('data-app-id', 'YOUR_APP_ID');
firebaseConfig.setAttribute('data-database-url', 'https://YOUR_PROJECT_ID.firebaseio.com');The database URL MUST be in the format: https://YOUR_PROJECT_ID.firebaseio.com
For example, if your project ID is space-invaders-game, your database URL should be:
https://space-invaders-game.firebaseio.com
The config.js file contains sensitive API keys and should NOT be committed to public repositories. It is already added to the .gitignore file to prevent accidental commits.
For your Firebase Realtime Database, set up the following security rules to allow read access to everyone but limit write access to only game score submissions:
{
"rules": {
"highscores": {
".read": true,
".write": true,
"$scoreId": {
".validate": "newData.hasChildren(['name', 'score', 'timestamp'])",
"name": {
".validate": "newData.isString() && newData.val().length <= 30"
},
"score": {
".validate": "newData.isNumber() && newData.val() >= 0"
},
"timestamp": {
".validate": "newData.isNumber()"
}
}
}
}
}- Open
index.HTMLin your web browser - Use arrow keys or on-screen controls to move
- Press spacebar or the fire button to shoot
- Collect power-ups for special abilities
- Submit your high score when the game ends
- Classic Space Invaders gameplay
- Power-ups: Shield, Spread Shot, and Slow Motion
- Mobile-friendly controls
- High score tracking with Firebase
- Retro sound effects and music