Skip to content

merkusvictory/platformer-level-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

34 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

HopIt

Turn a hand-drawn sketch into a playable platformer level in seconds.

๐ŸŽฎ Live demo โ†’ hopit.us

Sketch a level on grid paper, snap a photo, and HopIt converts it into a fully playable browser game โ€” complete with AI solvability analysis and an adaptive Hard Mode that remixes the level based on exactly where you died.


Features

  • Sketch โ†’ Play โ€” Upload a photo of any hand-drawn grid and play it instantly
  • Live Editor โ€” Paint and erase tiles directly on the canvas
  • K2 Think Analysis โ€” Streaming AI reasoning verifies if your level is beatable and flags design issues
  • Hard Mode โ€” Claude remixes your level with walkers, saws, crumble tiles, and flyers targeted at your death spots
  • Physics Tuner โ€” Adjust gravity, jump strength, speed, and friction in real time
  • Auto Mode โ€” Built-in decision-tree AI plays the level for you

Drawing symbols

Draw this Tile
Filled / shaded rectangle Platform
Triangle โ–ณ Spike (instant death)
Circle โ—‹ Player spawn
Star โ˜… Goal (finish)

Running locally

Prerequisites

1. Clone & install

git clone https://github.com/merkusvictory/platformer-level-builder.git
cd platformer-level-builder

# Install backend dependencies
cd backend && npm install

# Install frontend dependencies
cd ../frontend && npm install

2. Configure environment variables

# From the repo root
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env

Edit backend/.env:

# Required โ€” converts uploaded images to level grids
GEMINI_API_KEY=your_gemini_key_here

# Required โ€” powers Hard Mode level remixing (Claude Haiku)
ANTHROPIC_API_KEY=your_anthropic_key_here

# Optional โ€” enables the K2 Think solvability analysis panel
K2_API_KEY=your_k2_key_here
K2_API_BASE_URL=https://api.k2think.ai/v1

# Leave as-is for local dev; set to your Vercel URL in production
FRONTEND_URL=http://localhost:5173

# Port (default 3000)
PORT=3000

Edit frontend/.env:

# Leave empty for local dev โ€” Vite proxy forwards /api to localhost:3000
# Set to your Render backend URL for production
VITE_API_URL=

3. Start the servers

Open two terminals:

# Terminal 1 โ€” backend (port 3000)
cd backend
node server.js

# Terminal 2 โ€” frontend (port 5173)
cd frontend
npm run dev

Open http://localhost:5173.

The Vite dev server automatically proxies /upload, /verify, and /api to the backend โ€” no CORS issues, no extra config.


Project structure

platformer-level-builder/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ server.js                   # Express API โ€” /upload /verify /api/levels/hard-mode
โ”‚   โ”œโ”€โ”€ .env.example                # All environment variables with descriptions
โ”‚   โ”œโ”€โ”€ render.yaml                 # Render deployment config
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ geminiPipeline.js       # Gemini Vision โ†’ level JSON
โ”‚       โ”œโ”€โ”€ levelConverter.js       # Pipeline orchestration
โ”‚       โ”œโ”€โ”€ verificationEngine.js   # BFS reachability + K2 Think streaming
โ”‚       โ”œโ”€โ”€ hardModeEngine.js       # Deterministic hard mode fallback
โ”‚       โ”œโ”€โ”€ agents/
โ”‚       โ”‚   โ””โ”€โ”€ hardModeAgent.js    # Claude Haiku hard-mode remixer
โ”‚       โ””โ”€โ”€ config.js               # Grid dimensions (50ร—35)
โ””โ”€โ”€ frontend/
    โ”œโ”€โ”€ vite.config.js              # Dev proxy โ†’ localhost:3000
    โ”œโ”€โ”€ .env.example                # Frontend environment variables
    โ”œโ”€โ”€ vercel.json                 # SPA rewrite rule for Vercel
    โ””โ”€โ”€ src/
        โ”œโ”€โ”€ pages/
        โ”‚   โ”œโ”€โ”€ Upload.jsx          # Upload, camera capture, demo picker
        โ”‚   โ”œโ”€โ”€ Processing.jsx      # Upload progress
        โ”‚   โ””โ”€โ”€ Play.jsx            # Game engine โ€” canvas, physics, AI, editor
        โ”œโ”€โ”€ data/demoLevels.js      # 5 built-in demo levels
        โ””โ”€โ”€ components/             # Aurora, SplitText, StarBorder UI primitives

API reference

Method Path Description
POST /upload Multipart image โ†’ SSE stream โ†’ level JSON
POST /verify SSE stream โ€” BFS + K2 Think solvability verdict
POST /api/levels/hard-mode Claude hard-mode remix (deterministic fallback)
GET /health Health check

Tile reference

Value Tile
0 / "" Empty
"T" / 1 Platform
"S" Spike
"C" Coin
"G" Goal
"P" Player spawn
"W" Walker enemy
"F" Flyer enemy
"Z" Saw blade
"B" Crumble platform
"J" Spring

Controls

Input Action
Arrow keys / WASD Move
Space / Up / W Jump
R Respawn

Edit mode (click โœ EDIT): click or drag to paint tiles, right-click to erase, Ctrl+Z to undo.


Deployment

Frontend โ†’ Vercel

Setting Value
Root directory frontend
Build command npm run build
Output directory dist
VITE_API_URL Your Render backend URL

Backend โ†’ Render

Setting Value
Root directory backend
Build command npm install
Start command node server.js
Env vars Same as backend/.env.example

Deploy order: Render first โ†’ copy URL โ†’ set VITE_API_URL in Vercel โ†’ deploy Vercel โ†’ copy URL โ†’ set FRONTEND_URL in Render โ†’ redeploy Render.


Tech stack

Layer Stack
Frontend React 19, Vite, Tailwind CSS 4, Framer Motion, HTML5 Canvas
Backend Node.js, Express 5, Multer, Sharp
Vision AI Gemini 2.5 Flash โ€” image to level grid
Hard Mode AI Claude Haiku (Anthropic) โ€” adaptive level remixing
Solvability AI K2 Think V2 (MBZUAI) โ€” streaming BFS reasoning

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors