Randomness and Repeat
Lesson 13 of 16 · GDev.Micro
Procedural generation means building content with rules instead of placing every piece by hand. The level is made when the scene starts, so it can be different every time.
The simplest generator is a loop with randomness. A Repeat event runs its actions a set number of times, and each new coin gets a random position. In GDevelop that position comes from expressions like RandomInRange(30, 600).
This scene starts with no coins at all. Generate them when the scene begins, then press Restart a few times and compare the layouts.
In GDevelop, Repeat is its own event type: add a repeat event and give it a count. Random(), RandomInRange() and RandomFloat() are the built-in random expressions.
When the scene starts, create 5 coins at random positions.
Do it in the browser: a real game design tool, a short mission and instant feedback. No install.
Start this lesson — free