Having only one pattern isn't all that exciting. So let's quickly continue with creating a second one.
Attack pattern 2 will be quite different from attack pattern 1. We let the boss first pick a corner of the screen. We will use a new kind of script method for this called a switch
case.
It then zigzags across the screen, forcing the player to keep moving about to avoid being hit.
This script structure follows the same pattern as the first one. We start with receiving a pattern message. In the end, we let the script take another random pattern.
The interesting part takes place in the middle:
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 initially move to.1
and 4
in the set <switch> to pick random () to () block respectively.-200
and 150
respectively.200
and 150
respectively.200
and -150
respectively.-200
and -150
respectively.-100
to angle it just off the horizontal line.500
times.These two blocks inside the loop will cause the boss sprite to move in a zigzag pattern across the stage.
We now completed our second movement pattern. We changed the rotation style and created a list of starting points for the script to choose from. When the proper starting point and direction are set, we can smoothly move the enemy and have it bounce off the edges to create a zigzag pattern. Just one more to go and we have a complete boss fight (well, almost).
We can test the game now, but sometimes the movement of the boss will freeze when the third attack pattern gets selected. We can also test each attack pattern separately by just clicking on the proper script stack instead of running the entire program with the <green flag> button.
18.223.237.29