Skip to content

Rushant-123/Forge-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForgeAI - AI-Powered 2.5D Game Builder

Empowering the next billion game creators.

License: MIT Node.js Vite

ForgeAI is an end-to-end game development platform that uses AI to eliminate the technical barriers of game creation. Describe a game world, and watch AI generate everything you need - from tilemaps to characters to physics - then export a playable game.


The Vision

From Idea to Playable Game in Minutes

You Describe → AI Generates → You Customize → Export & Play

Who Needs This:

  • Indie Developers - Prototype games in hours, not weeks
  • Game Design Students - Focus on mechanics without needing art skills
  • Rapid Prototyping - Test 10 art styles without hiring artists
  • Content Creators - Build custom games for your audience

Core Features

Phase 1: World Generation

  • Text-to-Tilemap: Describe a scene ("medieval castle with dark forest") and AI generates a 1024x1024 pixel tilemap
  • Image-to-Tilemap: Upload reference art and AI converts it to game-ready format
  • Auto Object Detection: AI identifies all game objects with precise 32-pixel grid coordinates
  • Multi-Model AI: Azure OpenAI for understanding + Google Gemini for generation

Phase 2: Object Management

  • Smart Object Grid: All objects placed on 32-pixel grid for perfect collision
  • Add/Remove/Edit: Describe new objects ("add a dragon"), remove unwanted ones
  • Sprite Customization: Edit or generate custom sprites for any object
  • Undo/Redo System: Full modification history with state management

Phase 3: AI Refinement

  • Conversational Editing: "Make forest denser" or "Add mountains in background"
  • Stateful Context: AI remembers your entire game world across modifications
  • Iterative Workflow: Keep refining until it's perfect
  • Non-Destructive: Original tilemap preserved for reference

Phase 4: Character Design

  • AI Sprite Generation: Generate animated character spritesheets from text
  • Advanced Sprite Editor: Cut frames, extract sprites, build animations
  • Timeline System: Visual animation designer with frame preview
  • Asset Library: Save and reuse custom sprites across projects
  • Default Characters: Pre-built Pokemon-style character with walk animations

Phase 5: Physics & Gameplay

  • Rigidbody System: Configure static/dynamic/kinematic physics per object
  • Collision Detection: Kaplay-powered collision with customizable layers
  • Custom Behaviors: Add scripted behaviors (blast on collision, teleport, etc.)
  • Keyboard Controls: Map WASD/Arrow keys with custom move speeds
  • Real-Time Preview: Test your game instantly with Kaplay engine

Phase 6: Live Game Preview

  • Playable Game: Fully functional 2.5D platformer in-browser
  • Character Animations: Walk cycles, idle poses, directional movement
  • Physics Simulation: Gravity, collision, movement - all working
  • Export Ready: Download Kaplay-compatible project files

Tech Stack

Frontend

  • Vanilla JavaScript - Modular ES6 architecture
  • Kaplay.js - 2D game engine for rendering and physics
  • HTML5 Canvas - Client-side image processing
  • Vite - Lightning-fast build tool and dev server

Backend

  • Node.js/Express - RESTful API architecture
  • Multer - File upload handling
  • Axios - HTTP client for AI model communication

AI Models

  • Azure OpenAI (GPT-4o-mini) - Object detection, scene understanding
  • Google Gemini (Vertex AI) - Image generation, sprite creation
  • Custom Coordinate Mapping - Translates AI probabilistic output to deterministic game positions

Project Structure

ForgeAI/
├── client/
│   ├── src/
│   │   ├── modules/              # Modular JavaScript components
│   │   │   ├── api-client.js     # API communication
│   │   │   ├── phase-4-manager.js   # Character customization
│   │   │   ├── phase-4-5-manager.js # Physics configuration
│   │   │   ├── game-preview.js      # Live game rendering
│   │   │   ├── default-character.js # Pre-built sprite system
│   │   │   └── ...
│   │   └── styles/
│   │       └── styles.css        # Dark theme UI
│   ├── public/
│   │   └── assets/               # Default character sprites
│   ├── index.html
│   └── package.json
│
├── server/
│   ├── modules/
│   │   ├── gemini-client.js      # Google Gemini integration
│   │   ├── azure-client.js       # Azure OpenAI integration
│   │   └── coordinate-mapping.js # Grid alignment system
│   ├── routes/
│   │   ├── tilemap.js            # Tilemap generation endpoints
│   │   ├── sprite.js             # Character sprite endpoints
│   │   ├── physics.js            # Physics rule endpoints
│   │   └── ...
│   ├── index.js                  # Express server entry
│   └── package.json
│
├── vercel.json                   # Vercel deployment config
└── README.md

Getting Started


Quick Start

Prerequisites

  • Node.js 18+
  • Azure OpenAI API key
  • Google Cloud Vertex AI credentials

Installation

# Clone the repository
git clone https://github.com/Rushant-123/Forge-AI.git
cd Forge-AI

# Install dependencies
npm install

# Setup client
cd client
npm install
cd ..

# Setup server
cd server
npm install
cd ..

Configuration

  1. Azure OpenAI Setup

    • Create file: server/.env
    • Add your Azure credentials:
    AZURE_OPENAI_API_KEY=your-key-here
    AZURE_OPENAI_ENDPOINT=your-endpoint-here
    AZURE_OPENAI_DEPLOYMENT_NAME=your-deployment-name
  2. Google Vertex AI Setup

    • Place service account JSON in: creds/vertex-nano-banana.json
    • Ensure file has required fields: project_id, private_key, client_email
  3. Verify Setup

    node server/check-env.js

Running the App

# Terminal 1: Start backend (port 3001)
cd server
npm run dev

# Terminal 2: Start frontend (port 3000)
cd client
npm run dev

Open http://localhost:3000 in your browser.


How It Works

The Complete Workflow

Step 1: Generate World

Input: "medieval castle with dark forest and river"
AI Output: 1024x1024 tilemap + 47 detected objects with grid coordinates

Step 2: Manage Objects

- Review detected trees, buildings, terrain
- Add: "dragon enemy sprite"
- Remove unwanted objects
- Edit existing sprites

Step 3: Refine with AI

Prompt: "Make the forest denser, add mountains in background"
AI updates tilemap while preserving object relationships

Step 4: Create Character

Input: "warrior character with sword and shield"
AI Output: 4-direction spritesheet with walk animations (4 frames each)

Step 5: Configure Physics

- Trees: Static rigidbody, collides with player
- Dragon: Dynamic rigidbody, custom blast behavior
- River: No collision (aesthetic only)
- Player: WASD controls, 150 move speed

Step 6: Play!

Export → Deploy to web → Share with friends

Technical Innovation

The Core Challenge: Making AI Deterministic

Problem: AI is probabilistic (gives different results each time), but games need deterministic positioning (collision breaks if objects are off by 1 pixel).

Our Solution: Custom Coordinate Mapping

// AI says: "tree at (527, 391)" (pixel coordinates)
// We translate to: grid cell (16, 12)
// Which becomes: game coordinate (512, 384) (grid-aligned)

const gridX = Math.floor(pixelX / GRID_SIZE) * GRID_SIZE;
const gridY = Math.floor(pixelY / GRID_SIZE) * GRID_SIZE;

This ensures:

  • Objects snap to 32-pixel grid
  • Collision detection works perfectly
  • Physics simulation is stable
  • Consistent positioning across AI calls

Hackathon Submission

Theme: Human + AI: Co-Creation for the Future

Tagline: Empowering the next billion game creators.

Biggest Challenge Solved: Making AI deterministic for game development through custom grid-snapping coordinate translation and stateful multi-model context management.


Deployment

Deploy to Vercel

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel deploy --prod

The vercel.json configuration is already set up for both client and server deployment.

Environment Variables for Production

Add these to your Vercel project settings:

AZURE_OPENAI_API_KEY=your-key
AZURE_OPENAI_ENDPOINT=your-endpoint
AZURE_OPENAI_DEPLOYMENT_NAME=your-deployment

Upload your Vertex AI credentials JSON as a Vercel secret.


Documentation

Detailed technical documentation is available in the docs/ folder:

Setup & Configuration

Architecture & Systems

Phase-Specific Documentation

Feature Documentation

Development

  • Agents - AI agent configurations and workflows

License

This project is licensed under the MIT License - see the LICENSE file for details.


Acknowledgments

  • Kaplay.js - 2D game engine
  • Azure OpenAI - Language understanding and object detection
  • Google Gemini - Image generation capabilities
  • Vite - Build tool and development server

Contact & Support


Built for the AI + Gaming community

Star this repo | Report Bug | Request Feature

About

AI-powered 2D game builder with natural language. Create tilemaps, sprites, and game logic by describing what you want. Built with Gemini AI + Kaplay.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors