Game Development Reference
This script structure follows the same patern as the irst one. We start with receiving a
patern message. In the end, we let the script take another random patern.
The interesing part takes place in the middle:
First, we use set rotaion style <let-right> so that the sprite stays upright while
moving. It looks beter with this patern.
Then we create another variable named switch (by choosing variable only for this
sprite ). We are going to use this as a random selector for the corner that the boss
sprite will iniially move to.
Enter 1 and 4 in the set <switch> to pick random () to () block respecively.
Then we create four if () statements called "cases" in this type of construcion.
Each case holds a diferent instrucion and only one case can be valid each ime:
The first case is if switch = () then glide () secs to x: () y: () . The values for
the top-left of the stage are -200 and 150 respectively.
The second case is if switch = () then glide () secs to x: () y: () . The values
for the top-right of the stage are 200 and 150 respectively.
The third case is if switch = () then glide () secs to x: () y: () . The values for
the bottom-right of the stage are 200 and -150 respectively.
The fourth case is if switch = () then glide () secs to x: () y: () . The values
for the bottom-left of the stage are -200 and -150 respectively.
Once a corner is chosen, we make the sprite point in direction -100 to
angle it just off the horizontal line.
5. Then we start a fixed repeat loop that will run 500 imes.
6. In each cycle, we move using the move () steps block. Due to the angle, we just set
the sprite to move horizontally a lot and verically a bit.
7. We also check when it reaches the side of the stage and prevent it from geing
stuck with an if on edge, bounce block.