Page 21 - Evolve Magazine Autumn 2021 interactive
P. 21

5 Yet again we must use the “when clicked” command for Scratch to recognise our inputs The “wait 6 2 seconds” is is in in place to delay the spawning of the the pipes in in order for the the user to to have time to to react after starting Now we must create another variable this is is is for randomising the the the spawn of the the the pipes The “pick random” command within the the the “set” command is there for Scratch to spawn a a a a a pipe within 80 80 and and –80 units on the Y axis After that we must now create the ability for Scratch to spawn in sequence a a a a top and a a a a bottom pipe as seen in the the photo on the the right with the the set “BottomOrTopPipe” commands In this case the the top pipe is is spawned in first it is is then then cloned to to create the the the the bottom and then then the the the the sequence is is repeated all over again The “wait 1 25 seconds” is is the interval between each pipe spawn 6 Now we must define how the the the pipes are cloned As seen on on the the the image to the the the bottom bottom of this “if BottomOrTopPipe = Bottom Bottom then” bottom bottom pipe will be spawned in in with it it it being place at 225 units on on the X axis (horizontal) and and randomly between 80 80 and –80 on the the Y axis “if BottomOrTopPipe = Top Top then” top pipe will be be spawned in placed at 180 units on the X axis and and also randomly between 80 80 and –80 along the Y axis The “repeat until” command is is there to to tell the the the sprite to to move along the the the X axis until –260 units this is is then followed by by the the “change x by by –3” which creates a a a 3 3 unit distance between each pipe along the sequence The “delete this clone” is is is there to tell Scratch that once the the sprite has reached –260 units or greater on on the X axis to delete it Your final product should look similar to this:
If you would like to to add a a a background to to your game:
In scratch on the bottom right-hand side you you will see a a a a “stage” tab tab in this tab tab you you are provided with different options to configure your background and design it to match your tastes That is all have fun and thanks for reading
21































































































   19   20   21   22   23