To simplify the script creation, we will start with the starter project. The starter project contains the following:
Open the starter project and check out the stage, global variables, and the sprites.
The costume stage in Space Age is imported from the Scratch media library under Space. It does not have any script and is only used for the background.
Open the starter project and check out the sprites included. The following table gives a quick overview of what each sprite does:
Sprite name |
Description |
Scripts included in starter project? |
---|---|---|
Spaceship |
No | |
Spaceship Ammo |
No | |
Shield |
Protects the Spaceship against enemy crash but not against the enemy ammo |
No |
Shield Life |
Displays the power level of the shield |
No |
Life Boost |
Resets shield power to full |
Yes |
Laser Boost |
Increases laser power to shoot through all enemies on the laser track |
Yes |
Rock |
Enemy sprite that falls |
Yes |
Mother Ship |
Enemy sprite that flies in a pattern |
Yes |
Enemy Ammo |
Ammo fired by the enemy sprites |
Yes |
Game Manager |
Manager's game levels and scores |
Yes |
Start Button |
Yes | |
Hundredth |
Display the hundred's digit of the score |
Yes |
Tenth |
Display the ten's digit of the score |
Yes |
One |
Display the one's digit of the score |
Yes |
Global variables are variables that are shared by all sprites and local variables are variables used by one sprite only. Global variables are convenient for sprites to share information, just like a bulletin board. You may think of global variables as posts on a bulletin board for all sprites to see, and local variables as private letters just for the eyes of the owner sprite.
To create a global variable, just select the For all sprites radio button as shown in the following screenshot:
In Space Age, there are six global variables: enemy_count
, frame_rate
, game_level
, game_score
, power_boost_on
, and max_game_level
. Their description is given in the following table:
Global variable name |
Description |
---|---|
|
Current count of enemies in game |
|
The frame refresh rate; often used to pause for the costume |
|
Current level of the game; range— |
|
Current game score; range— |
|
True if spaceship's laser boost is on; false if it is off |
|
Highest level in this game |
18.221.163.13