🎮

Platformer Chunks

gameType: "platformer-chunk"

Rhythm-based platform placement with jump arc validation. Generates platforms, hazards, collectibles, entry and exit points. Every chunk is validated for completability via jump physics BFS — the exit must be reachable, and all collectibles are checked for accessibility.

Interactive Example

🎮 Platformer Chunk

Rhythm-based platform placement with jump arcs

difficulty: 0.40completable ✓
🪙
🪙
🪙
🏃
🔺
🔺
Solid Platform🏃 Entry⭐ Exit🪙 Coin🔺 Hazard

Platforms

3

Hazards

2

Collectibles

3/3

Jump Height

4 cells

Try it

await pf.generate({
  gameType: "platformer-chunk",
  params: { width: 25, height: 12, jumpHeight: 4, platformDensity: 0.3 },
  count: 1,
  difficulty: { target: 0.50 }
})

API Parameters

ParamTypeRequiredDefaultDescription
widthnumberYes30Chunk width in cells. Range 15–60.
heightnumberYes15Chunk height in cells. Range 8–25.
platformDensitynumberNo0.3Platform density (0.1–0.8). Higher = more platforms.
hazardDensitynumberNo0.15Hazard density (0.0–0.6). Higher = more spikes/lava.
jumpHeightnumberNo4Maximum vertical jump in cells (2–8).

Generation Details

The platformer chunk generator follows this process:

  1. Fill bottom row with solid ground
  2. Place platforms left-to-right in rhythmic groups, each reachable from the previous
  3. Horizontal gaps and vertical offsets scale with difficulty
  4. Platform widths decrease with difficulty (narrower = harder)
  5. Entry placed on the left ground, exit on the right (ground or last platform)
  6. Hazards placed on ground and between platforms (density scales with difficulty)
  7. Collectibles scattered above platforms and in jump arcs
  8. Validate: exit reachable via jump physics BFS, check all collectible accessibility

Jump Physics

The validator simulates platformer movement to verify completability:

  • Walk: Move left/right on solid ground or platforms
  • Jump: When grounded, jump up to jumpHeight cells vertically
  • Jump arc: Horizontal reach up to 1.5× jump height during jumps
  • Running jump: Horizontal leap without height gain (jumpHeight+1 cells)
  • Gravity: Fall when not standing on solid/platform cells

Content Output

ParamTypeRequiredDefaultDescription
gridPlatformerCell[][]Cell types: "empty", "solid", "platform", "hazard", "collectible", "entry", "exit".
platformsPlatform[]Platform objects with x, y, width, and id.
hazards[y,x][]Hazard positions.
collectibles[y,x][]Collectible positions.
entry[y,x]Level entry point.
exit[y,x]Level exit point.
jumpHeightnumberJump height used for validation.

Example Request

bash
curl -X POST https://api.gameplaygen.com/generate \
  -H "Authorization: Bearer gg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "gameType": "platformer-chunk",
    "params": { "width": 40, "height": 15, "jumpHeight": 4, "platformDensity": 0.3 },
    "count": 3,
    "difficulty": { "target": 0.5 }
  }'

Tips for Game Integration

  • Infinite runner: Chain multiple chunks by matching exit→entry positions for endless levels.
  • Difficulty progression: Generate chunks with ascending difficulty for a complete level arc.
  • Collectible challenges: Use metrics.solution.collectiblesReachable for "collect them all" objectives.
  • Custom physics: Adjust jumpHeight to match your game's feel (higher = more forgiving).