Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AI Asteroids is a fast-paced, retro-inspired space shooter where you pilot a starfighter, dodge asteroids, and blast enemy UFOs—now enhanced with dynamic AI-generated mission briefings and post-flight debriefs for a new experience every run. ⭐️ Star to support my work!

License

Notifications You must be signed in to change notification settings

RichLewis007/AI-Asteroids

Repository files navigation

AI Asteroids

License Version

Current Version: v.009

AI Asteroids Banner AI Asteroids Banner

Fake Legal Disclaimer: These graphics are in no way intended to represent actual in-game graphics. In fact, they are meant to be deceiving, just as the original game packaging on contemporaneous retro games deceived millions of innocent children into buying games like Asteroids™. You have been warned.

Try it here!

Play AI-Asteroids in your web browser

Note: AI features are disabled in this public web version to prevent triggering billing on the developer's Gemini API key.

Description

  • Fly through space in your web browser, shooting asteroids and bad guys!
  • A very simple in-browser game. Simple graphics. Simple sound. But cool AI!
  • All code in the 1 html file.

Features

  • Control your ship using the keyboard or mouse, but in a different way from the traditional "Asteroids" games. Uee the WASD or cursor keys to move the spaceship, and use the mouse to aim the ship's blaster. Press space or left click to shoot where the mouse pointer is aiming. I think this is a better way to control the ship than the old, keyboard-only setup. Do you?
  • Crazy simple sound effects, with custom composed explosion sound, etc.
  • CRAZY SPACE ACTION!
  • Uses Tone library for sounds: https://tonejs.github.io/

Generative AI features

Dynamic Mission Briefings and After-Action Reports, stories which will be different every time!!

Dynamic Mission Briefings: Each time you start a new game, a unique mission objective is generated by the Gemini API. You might be tasked with defending a mining colony, escorting a diplomat, or clearing a pirate blockade, adding a new narrative flavor to every session.

After-Action Reports: When your game is over, the screen smoothly fades to black, then immediately displays a cool high-tech loading screen with animated grids, progress bars, and status messages while Gemini generates a personalized, heroic "After-Action Report" based on your final score. The entire experience is seamless and entertaining for about 15 seconds. It's a fun way to commemorate a great run!

Both features include loading indicators while the AI generates the text.

Uses the Gemini API for the generative AI stories.

Example Mission Briefing:

Urgent: The Xylos Swarm is assaulting the Jupiter Relay Station! Their bio-weapons will cripple our comms if they succeed. Protect the station at all costs, pilot! Wipe out every last alien before they breach our defenses!

Example After-Action Report:

After-Action Report: Pilot Ensign Kira "Dodger" Bellweather

Despite a final score of zero, Ensign Bellweather displayed a truly unparalleled mastery of evasive maneuvers during the recent engagement with the Xylosian raiders. Their craft, "The Indomitable Blip," became an almost mythical target, leading enemy fighters on a wild goose chase through the asteroid field and, according to post-mission comms, narrowly avoiding no fewer than seven head-on collisions with both hostile ships and conveniently placed galactic debris. While no hostile vessels were destroyed by their direct action, Ensign Bellweather's unique talent for almost being annihilated undoubtedly diverted a significant amount of enemy ordnance, effectively acting as the galaxy's most resilient, and frankly, luckiest, decoy. A true testament to the principle of "survival through sheer improbability.


Instructions for Setup

Here are the steps to run the full version of the game from GitHub:

  1. Get a Free API Key: Go to Google AI Studio:
  2. Create Key: Click the "Create API key" button. You may need to sign in with your Google account.
  3. Copy Key: A new API key will be generated. Copy this long string of letters and numbers.
  4. Update the Code: Open the index.html file in a text editor and find this line:
const API_KEY = ""; // Leave blank

Paste Your Key: Paste your copied API key between the quotation marks:

const API_KEY = "PASTE_YOUR_API_KEY_HERE";

Save and Run: Save the file and open it in a web browser. The mission briefings and after-action reports will now work.

Running Locally Setup

For developers who want to use the AI features locally without modifying the main index.html file, there's an automated local running setup:

Running Locally

  1. Set up your API key (recommended):

    # Copy the example file
    cp .env.example .env
    # Edit .env and add your actual API key

    Or manually create a .env file with:

    GEMINI_API_KEY=your_actual_api_key_here
    
  2. Generate the local html file:

    npm run dev

    This automatically creates local-index.html from the main index.html file, inserts your API key, and opens it in your browser.

  3. Run AI features: The file includes a "RUNNING LOCALLY" indicator and identical functionality to the main game

Benefits of Running Locally

  • Always up-to-date: Local html file is automatically generated from the latest source index.html
  • No maintenance: No need to manually sync changes between source and local run files
  • Safe development: Your API key stays local and won't be committed to GitHub
  • Identical functionality: Same game features as the main version
  • No conflicts: Doesn't affect the public GitHub Pages deployment
  • Auto-opens browser: Generated file opens automatically for immediate use

Development Workflow

# 1. Set up API key (one-time setup)
cp .env.example .env
# Edit .env with your actual API key

# 2. Make changes to index.html
# 3. Generate fresh local html file with API key
npm run dev
# 4. Run AI features locally

The local html file is automatically excluded from version control to keep your API key secure.

Getting Started

# Clone the repository
git clone https://github.com/RichLewis007/asteroid-blaster.git
cd asteroid-blaster

Usage

S.E.T.M. (Shoot Everything That Moves)

Changelog

See CHANGELOG.md for version history and release notes.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

For Developers

If you're interested in contributing to the codebase or understanding how the project works, see DEVELOPMENT.md for detailed technical documentation including:

  • Version management and automation
  • Development setup and workflow
  • Code architecture and features
  • Deployment processes

License

This project is licensed under the terms of the MIT license.

About

AI Asteroids is a fast-paced, retro-inspired space shooter where you pilot a starfighter, dodge asteroids, and blast enemy UFOs—now enhanced with dynamic AI-generated mission briefings and post-flight debriefs for a new experience every run. ⭐️ Star to support my work!

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •