Skip to content

HemJoshi111/asteroid-shooter-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Asteroid Shooter with AI Survival Tips

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.


๐ŸŒ Live Demo


Project Status License

๐ŸŽฎ Features

  • 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.

๐Ÿ› ๏ธ Technologies Used

  • 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".

๐Ÿ“‚ Project Structure

.
โ”œโ”€โ”€ 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

๐Ÿš€ Getting Started

Prerequisites

To run this game, you need:

  1. A modern web browser (Chrome, Firefox, Edge, Safari).
  2. A text editor (VS Code, Notepad++, etc.) if you wish to edit the code.
  3. A Google Gemini API Key (Get one for free at Google AI Studio).

Installation & Setup

  1. Clone or Download this repository to your local machine.
  2. Open the project folder.
  3. Configure the API Key (Crucial Step):
    • Open script.js in 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.
  4. Run the Game:
    • Simply double-click index.html to launch the game in your browser.

๐Ÿ•น๏ธ Controls

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)

๐Ÿค Contributing

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.

๐Ÿ“„ License

This project is open-source and available for personal and educational use.

About

๐Ÿš€ A retro-style arcade shooter built with vanilla JavaScript and HTML5 Canvas. Features unique AI integration using the Google Gemini API to generate witty survival tips upon game over.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors