A browser-based 2D shooter game where you fight waves of ghosts across 10 levels, ending in a boss battle. Built with HTML5 Canvas and Firebase.
- Shoot incoming ghosts before they reach you
- Survive all 10 levels to win
- Level 10 spawns a boss enemy
- You have 3 lives — ghosts and boss lasers cost you one on contact
| Type | Color | Trait |
|---|---|---|
| Normal | Green | Standard speed |
| Fast | Cyan | 1.8x speed, smaller size |
| Tank | Orange | Slow, 3 HP, large size |
| Zigzag | Magenta | Moves in a wave pattern |
New ghost types unlock as you progress through levels.
| Action | Input |
|---|---|
| Move | A / D or Arrow Keys |
| Shoot | Click (aims toward cursor) |
| Action | Input |
|---|---|
| Move | Left joystick (bottom-left) |
| Shoot | Tap anywhere on screen |
- Kill ghosts to earn points and progress
- Each level requires more kills to advance
- Difficulty increases with each level (faster spawns, tougher ghosts)
The leaderboard reads and writes to a Firebase Firestore collection called leaderboard. Here's how each operation works and how to interact with it.
Each entry in the leaderboard collection looks like this:
{
"name": "PlayerName",
"score": 1500,
"level": 7,
"timestamp": 1711500000000
}| Action | When it happens | What it does |
|---|---|---|
| Load leaderboard | On page load + when leaderboard screen opens | Fetches top 10 scores ordered by score descending |
| Save score | When game ends (game over or victory) | Checks if player name exists — updates if yes, creates new entry if no |
You can read leaderboard data directly from Firestore using the Firebase REST API — no SDK needed:
GET https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/leaderboard
To filter and sort (top 10 by score), use the Firestore runQuery endpoint:
POST https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents:runQuery
Content-Type: application/json
{
"structuredQuery": {
"from": [{ "collectionId": "leaderboard" }],
"orderBy": [{ "field": { "fieldPath": "score" }, "direction": "DESCENDING" }],
"limit": 10
}
}POST https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/leaderboard
Content-Type: application/json
{
"fields": {
"name": { "stringValue": "PlayerName" },
"score": { "integerValue": 1500 },
"level": { "integerValue": 7 },
"timestamp": { "integerValue": 1711500000000 }
}
}Note: The REST API requires your Firebase project to have public read rules, or you'll need to pass an auth token via
Authorization: Bearer YOUR_TOKEN.
Scores are saved to a global Firebase leaderboard (top 10). If Firebase is unavailable, scores fall back to local storage.
Just open shooter.html in a browser — no build step needed.
# Or serve locally with any static server, e.g.:
npx serve .- HTML5 Canvas
- Vanilla JavaScript
- Firebase Firestore (leaderboard)
- Web Audio API (sound effects)
- Email: infomorile@gmail.com
- Location: Lagos, Nigeria