A classic retro-style arcade game built with vanilla JavaScript, HTML5 Canvas, and Tailwind CSS. This project features a unique integration with Google's Gemini API to provide witty, sarcastic, and helpful "Survival Tips" whenever the player loses.
- Classic Arcade Physics: Smooth thrust, rotation, and friction mechanics simulating zero-gravity inertia.
- Infinite Gameplay: Progressive difficulty; as you clear levels, asteroid counts increase.
- AI Integration: Uses Google's Gemini API to analyze your final score and level to generate unique, context-aware game-over advice.
- Responsive Design: The game canvas scales automatically to fit different screen sizes.
- Retro Aesthetic: Vector-style neon graphics, CRT-inspired visuals, and "Press Start 2P" typography.
- HTML5 Canvas - For high-performance 2D rendering.
- Vanilla JavaScript (ES6+) - Handles the game loop, physics engine, and API logic.
- Tailwind CSS - Used for the UI overlay and responsive layout.
- Google Gemini API - Powers the generative AI "Survival Tips".
.
โโโ index.html # Main entry point; loads CSS and JS
โโโ style.css # Visual styles, fonts, and responsive rules
โโโ script.js # Core game logic, physics, and AI integration
To run this game, you need:
- A modern web browser (Chrome, Firefox, Edge, Safari).
- A text editor (VS Code, Notepad++, etc.) if you wish to edit the code.
- A Google Gemini API Key (Get one for free at Google AI Studio).
- Clone or Download this repository to your local machine.
- Open the project folder.
- Configure the API Key (Crucial Step):
- Open
script.jsin your text editor. - Locate the
getSurvivalTip()function (approx. line 350). - Find the line:
const apiKey = ""; - Paste your actual Gemini API key inside the quotes.
- Example:
const apiKey = "AIzaSyD-Your-Actual-Key-Here"; - Note: Without this key, the "Survival Tip" feature will return a simulated error message.
- Open
- Run the Game:
- Simply double-click
index.htmlto launch the game in your browser.
- Simply double-click
| Key | Action |
|---|---|
| โฌ๏ธ Up Arrow | Thrust / Move Forward |
| โฌ ๏ธ Left Arrow | Rotate Ship Left |
| โก๏ธ Right Arrow | Rotate Ship Right |
| Spacebar | Shoot Laser |
| Click "Get Survival Tip" | Ask AI for advice (Available on Game Over screen) |
Contributions are welcome! If you'd like to improve the game (e.g., add sound effects, mobile touch controls, or local high scores), feel free to fork the repository and submit a pull request.
This project is open-source and available for personal and educational use.