Game Development Reference
In-Depth Information
Engage thrusters
To show the game screen at the right moment and to display the proper costume,
we will use a script as shown in the following steps:
1. Click on the Scripts tab to add some scripts to the game screen.
2. Start a new when <green lag> clicked script.
3. Atach a go to x: 0 y: 0 block to place the screen at the center of the stage.
4.
Then, hide it to start the game without displaying the game screen.
5.
Start a second script with a when I receive … block.
6.
Create the new message game over .
7.
Add a switch costume to <costume 2> block.
8.
Then display the game screen by clicking on show .
9.
Place a stop <all> block to stop all scripts to end the game.
Scriping for the win condiion is a bit more work. When does the player win the game?
When all the enemies have been killed or have entered the base while the base has not
yet been destroyed. The last part of that condiion is already taken care of because the
scripts we have just writen will put the game in the game over state as soon as the base
is destroyed. If we haven't reached the game over state yet, the base must sill be "alive".
So we only have to take care of couning the enemies and check whether we have reached
the total yet.
First, count the total number of enemies that are spawned during the game. If you've used
the numbers menioned earlier, there should be 35 enemy clones moving through the game.
Remember that number. The following are the steps to count the number of enemies:
1. Create another variable called enemies .
2. Use the Set enemies to 0 block at the start of the game screen <green lag> script.
3. We will check for the win condiion at the end of the script. Add a wait unil
block.
4. Plug in the condiion enemies = 35 .
5. When this condiion has been met, the script coninues with switch to
costume <costume1> .
6. Click on Show to make the sprite visible.
7. Use stop <all> to stop all scripts to end the game.
8. Now let's start couning so the win condiion can be met.
9.
Go to the red enemy's Scripts tab.
 
Search WWH ::




Custom Search