🚀 About the Project: Airsofte

Inspiration

Airsofte started as a love letter to classic arcade space shooters, the kind of games where everything was immediate. Movement, shooting, feedback, and failure all happened instantly. No long tutorials or cutscenes, just skill, reaction time, and learning enemy patterns.

I wanted to recreate that tight retro gameplay feel while exploring how Google Gemini API could enhance it without taking control away from the player. The goal was not to let AI play the game, but to let it react to the player, comment on what is happening, and influence how the game evolves in real time—making every playthrough feel unique and personalized.

What I Learned

This project pushed me to think beyond simply making a game and instead focus on systems design, AI integration, and long term maintainability.

From a game development perspective, I learned how to structure a real time game loop inside a desktop environment without frame drops, why object pooling and spatial partitioning are essential once entity counts increase, and how small details like screen shake, hit stop, and particle timing dramatically affect how a game feels.

From a software architecture perspective, I learned how to design an event driven system where combat, audio, UI, and AI do not depend directly on each other, how to separate state, rendering, and effects cleanly, and why AI features need clear triggers and constraints to feel intentional rather than random.

From an AI integration perspective, I learned how to structure prompts for consistent game-ready responses, how to balance AI response times with gameplay feel (sub-500ms for real-time features), why session-based context makes AI behavior feel coherent rather than random, and how to gracefully degrade when AI requests fail or timeout.

How I Built It

Airsofte is split into three major systems, each with a clear responsibility.

1. Desktop Game Client

The core game runs as a desktop application built with Electron, while all gameplay and rendering are handled using Svelte 5 and its rune based reactivity model.

The desktop client is responsible for:

  • Rendering the game at 60 FPS
  • Running the game loop and physics
  • Handling input and combat
  • Playing animations and audio
  • Managing local persistence (high scores, settings, story progress)
  • Triggering AI requests via event bus

Key internal systems include:

  • A central game manager that controls state, waves, scoring, and win/loss conditions
  • An event bus that allows systems to communicate without tight coupling
  • A collision and combat system using AABB checks and spatial grids
  • Object pools for bullets, enemies, particles, and power ups
  • A fully event driven audio system built with Howler.js
  • AI event listeners that trigger Gemini requests at key gameplay moments

All gameplay logic is written in TypeScript with strict typing enabled across the entire codebase.

2. Web Layer

In addition to the desktop client, Airsofte includes a web layer used for routing, menus, modals, settings screens, and story mode flow.

This layer keeps presentation and navigation separate from core gameplay logic, making the codebase easier to reason about and extend. It also makes future expansion possible, such as web builds, dashboards, or multiplayer related features, without rewriting the core game systems.

3. AI Backend Server

This is where Gemini integration happens. AI powered features are handled by a separate Node.js + Express backend that securely interfaces with the Google Gemini API.

The server exists to:

  • Keep API keys off the client (security)
  • Apply rate limiting and validation
  • Provide structured AI responses that the game can safely consume during gameplay
  • Maintain session context across multiple AI requests
  • Cache frequently requested content (mission generations)

It currently supports:

  • Real-time tactical hints (Gemini 1.5 Flash - <500ms responses)
  • Dynamic mission generation (Gemini 1.5 Pro - 2-4 second generations)
  • Live AI commentary during gameplay (Gemini 1.5 Flash - <800ms)
  • Adaptive boss behavior (Gemini 1.5 Pro - <1 second at health thresholds)
  • Post-mission reports (Gemini 1.5 Flash - optional feature)

All AI requests are triggered by in-game events, meaning the game always decides when and why AI input is needed. The player never waits on AI—if a request times out, the game continues normally with fallback behavior.

Gemini Integration: Core to the Experience

Airsofte is fundamentally different with Gemini than without it. Here's how each integration transforms gameplay:

1. Real-Time Tactical Advisor

Traditional games give you the same advice every time. Gemini analyzes your exact situation (current health, equipped weapon, enemy formation, wave number) and provides contextual tactical recommendations.

Example: Fighting 5 basic enemies + 2 fast attackers with 40% health and spread shot equipped? Gemini might say: "Your spread shot is perfect for clustered formations, but prioritize the fast enemies first—they'll overwhelm you at low health."

Same situation with rapid fire? Different advice. Same weapon at full health? Different advice. Context matters.

2. Dynamic AI Commentary

Solo gameplay can feel lonely. Gemini acts as a live commentator, reacting to your combos, close calls, and boss victories with natural language that adapts to your playstyle.

Aggressive players who take risks get different commentary than defensive players who play cautiously. Pull off a 20-combo streak? Gemini celebrates. Nearly die and recover? Gemini reacts with tension. Every playthrough sounds different.

3. Adaptive Boss Encounters

Most games have bosses with scripted attack patterns. Airsofte's bosses learn from you.

At 75%, 50%, and 25% health, the boss sends your combat data to Gemini (dodge success rate, preferred weapon range, average DPS). Gemini analyzes your playstyle and generates new attack behaviors, movement patterns, and aggression settings.

The same boss literally fights differently based on how YOU fight. If you're good at dodging close-range, the boss switches to area-denial attacks. High DPS? The boss spawns support drones to split your attention.

4. Procedural Mission Generator

Players can generate completely unique missions by specifying difficulty, theme, and wave count. Gemini creates the entire mission: title, description, objectives, balanced enemy wave compositions, pre-mission dialogue, and difficulty curves.

Missions aren't random—they're intelligently designed by Gemini to match your requested difficulty while respecting game balance. Want a "hard" mission themed around "asteroid field combat"? Gemini generates a complete, playable mission that actually feels hard and contextually appropriate.

Rate limited to 5 generations per hour to prevent abuse while maintaining good UX.

Challenges

Technical Challenges

  • Maintaining stable 60 FPS in Electron while rendering 100+ entities
  • Ensuring AI responses were fast enough to feel real-time (<500ms for hints)
  • Preventing AI features from distracting from core gameplay
  • Keeping the codebase modular as systems continued to grow

AI Integration Challenges

  • Prompt engineering for consistent, parseable JSON responses
  • Handling network failures gracefully without breaking game flow
  • Balancing AI creativity with gameplay balance (missions can't be impossible)
  • Maintaining session context across multiple requests without losing coherence
  • Rate limiting without degrading user experience

An event-driven architecture and strict separation of concerns were critical in solving these problems. AI features are completely decoupled from core gameplay—if the backend is down, the game still works.

Why This Project Matters

Airsofte is not just a retro shooter with AI tacked on. It's an exploration of how AI can enhance moment-to-moment gameplay without removing player agency.

It demonstrates:

  • How AI can behave as a reactive system inside a game
  • How clean architecture enables experimentation without chaos
  • How modern web technologies can build performance-sensitive desktop apps
  • How Gemini's fast inference and context understanding enable real-time gameplay features

Most importantly, it proves that AI in games doesn't need to replace player skill—it can amplify the experience.

What's Next

Planned improvements include:

  • Additional story missions with AI-generated dialogue
  • More AI-driven boss types with unique adaptation patterns
  • Online leaderboards
  • Gamepad support
  • Cloud saves synced with user accounts
  • Cooperative or challenge-based modes
  • Expanded Gemini features: AI-generated weapon descriptions, dynamic difficulty adjustment, personalized training missions

Built for the Google Gemini Developer Competition

Airsofte showcases how Gemini can transform traditional game genres through real-time analysis, natural language generation, and adaptive gameplay systems.

Built With

  • electronjs
  • gsap
  • howler
  • svelte
  • swagger
  • tailwindcss
Share this project:

Updates