Game Development Reference
In-Depth Information
20. Do this for all the shards that you've drawn. The following screenshots show the
base in various stages of decay:
Engage thrusters
Go to the script tab to write the scripts that make the base move through all of its
costumes and then break apart. You might think we will use a collision check like we did
with the enemies, but this not the case. The enemies will keep moving some distance after
they irst hit the base, unlike the bullets, which are destroyed on contact. This coninued
contact would mean that the collision check is acivated coninuously, quickly going through
all base costumes.
Instead of a collision check, we will use the broadcast method to make sure each hit is only
counted once. In a later project, we will do more with broadcasts and explain how they work.
The following are the steps to do it:
1. Start a new script on the base with a when I receive … block.
2. Create a new message and name it reached base .
3. Atach a next costume block to step to the next costume when the message is
4. Add an if … then ... block to check whether the base has reached its last costume.
5. Grab a = operator and the costume# variable for the base.
6. Put them together and write 20 in the open slot.
7. Inside the if statement, place a stop <all> block to terminate all scripts, efecively
ending the game.
8. We sill have to put the base in the right posiion. So start a new script with a when
<green lag> clicked block.
9. Add a go to x: … y: … block.
10. Fill in the numbers to place the base at the right end of the road. I used the values
240 and -5 for the x and y coordinates respecively. But your coordinates might be a
bit different.
11. Use the Switch costume to <base1> block to make sure the game starts with the
first (full health) image showing.
Search WWH ::

Custom Search