Back to Prompt Library
Games

2D Platformer

Simple endless runner platformer - jump over gaps and obstacles to survive

Guide

2D Platformer

Build a simple endless runner platformer where you control a square jumping over gaps and obstacles.

No Setup Required

This is a frontend-only game. Just run it and play!

Controls:

  • Keyboard: Space or Up arrow to jump

  • Gamepad: A button to jump
  • Final Prompt

    ### Purpose
    Build a simple 2D platformer endless runner game that runs in the browser.
    
    ### Game Design
    
    **Visual Style**
    - Minimalist geometric aesthetic
    - Player is a colored square/block
    - Platforms are simple rectangles
    - Clean background with parallax scrolling layers
    - Subtle particle effects on jump and landing
    
    **Player Character**
    - Simple square shape with a face or eyes for personality
    - Smooth jump arc with gravity
    - Can jump while on ground only (no double jump)
    - Squash and stretch animation on jump/land
    - Death animation: block shatters into pieces
    
    **World & Obstacles**
    - Auto-scrolling from right to left
    - Platforms at varying heights
    - Gaps between platforms (must jump over)
    - Spike obstacles on platforms (instant death)
    - Moving platforms (up/down or left/right)
    - Low ceiling sections (timing required)
    
    **Difficulty Progression**
    - Speed gradually increases over time
    - Gaps get wider
    - More obstacles appear
    - Moving platforms move faster
    - Difficulty resets on death
    
    **Scoring**
    - Score increases with distance traveled
    - Bonus points for close calls (near-miss spikes)
    - High score saved to localStorage
    - Current score and high score displayed
    
    **Game Flow**
    - Start screen with game title and "PRESS TO START"
    - Tap/click anywhere or press button to begin
    - Game starts immediately after input
    - Death shows "GAME OVER" with final score
    - "TAP TO RETRY" or press button to restart
    
    ### Controls
    
    **Keyboard**
    - Space: Jump
    - Up Arrow: Jump
    - Enter: Start game / Restart
    
    **Gamepad Support (IMPORTANT)**
    The entire game must be playable with a gamepad controller, including menus:
    - Use the Gamepad API: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API
    - A button (buttons[0]): Jump
    - A button on start screen: Begin game
    - A button on game over: Restart game
    - Start button (buttons[9]): Pause game
    - Show "Gamepad Connected" message when controller detected
    - Poll gamepad state in game loop using `navigator.getGamepads()`
    
    **Touch Support**
    - Tap anywhere on screen to jump
    - Works on mobile devices
    
    ### Technical Notes
    - Use HTML5 Canvas for rendering
    - 60 FPS game loop with requestAnimationFrame
    - Simple physics: gravity constant, jump velocity
    - Procedurally generate platforms ahead of player
    - Remove off-screen platforms for performance
    - Responsive canvas that scales to fit screen
    - No external dependencies needed
    AI-Powered App Builder | OptiDev