Rules and constraints
Lesson 15 of 16 · GDev.Micro
Random heights for platforms sound fine until one appears too high to reach. A generator that can produce impossible levels is a broken generator.
Good generators combine randomness with constraints: rules every result must respect. The player jumps about 100 px, so each platform may rise at most 85 px above the previous one. Inside that rule, anything goes.
Order matters again: create the platforms first, then place a coin above each one. Watch Biggest step up in the debugger and compare the two generators.
Games like Spelunky mix handmade room templates with random rules, so every level is new and still solvable. Constraints are the part of a generated level the designer still controls.
Generate the platforms with the 85 px rule, then place a coin above each platform.
Do it in the browser: a real game design tool, a short mission and instant feedback. No install.
Start this lesson — free