CompiledFrog

Post #71: Random Dice Spawning

Continuing through the tutorial series, today was about using randf_range() in order to change the starting position of the dice that fall. Here is the code snippet:

position.x = randf_range(
  get_viewport_rect().position.x + BUFFER,
  get_viewport_rect().end.x - BUFFER
)

Here, BUFFER represents the dice width, so that the dice doesn't spawn too close to a side and is partially off screen.

Post71-Photo1_2026-08-02_compiledfrog