Place Platforms Randomly

In the first version of Escape, we placed the platforms ourselves, by specifying the position of each one. This meant every time someone played the game, the platforms were in the same spots. This is not necessarily a bad thing, because you can design the pit to be just as difficult as you like. In this version, try another strategy and place the platforms randomly. The three pictures that follow do not show the actual placement of platforms in the game. They help explain what you are doing in the calculations that actually place the platforms.

images/sidescroller/grid_1.png

To place the platforms randomly, while still making the game playable each ...

Get Learn Game Programming with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.