A fun space shooter game with power-ups, different enemy types, and a global leaderboard powered by Supabase.
- Multiple enemy types with different behaviors
- Power-up system (Rapid Fire, Multi Shot, Shield)
- Level progression with increasing difficulty
- Global leaderboard to compete with other players
- Visual effects and animations
- Use arrow keys to move your spaceship
- Press space to shoot
- Collect power-ups to gain special abilities:
- Purple: Rapid Fire
- Cyan: Multi Shot
- Green: Shield
- Defeat enemies to increase your score
- Submit your score to the leaderboard when the game ends
This game is built using:
- p5.js for game graphics and interaction
- Supabase for the online leaderboard
To run the game locally:
-
Clone the repository
git clone https://github.com/Bensaa12/Space-Invader.git cd Space-Invader -
Start a local server
- You can use Python's built-in HTTP server:
python -m http.server - Or use any other local server of your choice
- You can use Python's built-in HTTP server:
-
Open your browser and navigate to
http://localhost:8000
Feel free to contribute to this project by:
- Forking the repository
- Creating your feature branch (
git checkout -b feature/AmazingFeature) - Committing your changes (
git commit -m 'Add some AmazingFeature') - Pushing to the branch (
git push origin feature/AmazingFeature) - Opening a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with p5.js
- Backend powered by Supabase
- Deployed with GitHub Pages
The game is hosted at: https://bensaa12.github.io/Space-Invader/
Source code available at: https://github.com/Bensaa12/Space-Invader
This repository is set up to automatically deploy to GitHub Pages when changes are pushed to the main branch.
If you want to deploy this game to your own GitHub Pages:
-
Fork this repository
- Click the "Fork" button at the top right of this repository
-
Enable GitHub Pages
- Go to your forked repository's Settings
- Scroll down to the "GitHub Pages" section
- Under "Source", select "main" branch
- Click "Save"
- Your game will be available at
https://yourusername.github.io/repository-name/
-
Update Supabase Configuration (Optional)
- If you want to use your own Supabase instance, update the configuration in
sketch.js - Replace the Supabase URL and key with your own
- If you want to use your own Supabase instance, update the configuration in
This repository includes a GitHub Actions workflow that automatically deploys the game to GitHub Pages when changes are pushed to the main branch.
To use this workflow:
- Make sure your repository has GitHub Pages enabled in the Settings
- The workflow file is located at
.github/workflows/deploy.yml - Any push to the main branch will trigger a deployment
- You can also manually trigger a deployment from the Actions tab
- Create a Supabase account at supabase.com
- Create a new project
- Once your project is created, go to the SQL Editor
- Run the following SQL to create the leaderboard table:
CREATE TABLE leaderboard (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
email TEXT NOT NULL,
score INTEGER NOT NULL,
level INTEGER NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create an index for faster queries
CREATE INDEX leaderboard_score_idx ON leaderboard (score DESC);
-- Set up Row Level Security (RLS)
ALTER TABLE leaderboard ENABLE ROW LEVEL SECURITY;
-- Create a policy that allows anyone to insert
CREATE POLICY "Allow anonymous inserts" ON leaderboard
FOR INSERT WITH CHECK (true);
-- Create a policy that allows anyone to select
CREATE POLICY "Allow anonymous reads" ON leaderboard
FOR SELECT USING (true);- Go to the "Settings" > "API" section in your Supabase dashboard
- Copy your "Project URL" and "anon public" key
- Open the
sketch.jsfile - Replace the placeholder values with your actual Supabase credentials:
const SUPABASE_URL = 'your-project-url';
const SUPABASE_KEY = 'your-anon-key';The leaderboard stores email addresses to identify players. Email addresses are partially masked when displayed on the leaderboard to protect privacy.