Step 2: The procedure for generating sections
There is a character in our game that we can use to run our algorithm from. His name is Matt Hall, and he's one of the developers that built Crossy Road.
> Add a script to Matt by right-clicking on him.
The game has been programmed to send out a message "new section" to when a new section is required. We can detect that message and use this event to trigger the generation of a new section.
> Open Events and drag out "When a message of "message" is retrieved".> Rename "message" to "new section"
Now we can use the "Create new instance" block to create a new section.
> Open Draw and drag "Create new instance of class class" inside the message retriever block.
The road section is tagged "road section", so we will create a instance with that tag.
> Open Sensing and drag out "first instance by tag tag name". > Rename "tag name" to "road section". > Open Sensing again and drag out "class of myself". > Replace "myself" with "first instance by tag road section".
> In the "create new instance" block, replace "class class" with "class of first instance by tag road section".
Perfect. Now you can close this script, and make sure to save it when it asks. Then play the game again to test it out.
So far these instructions only create roads, so we'll improve this to randomly choose from the other sections.