Game Development Reference
In-Depth Information
Enemy Ammo moves down, but Spaceship Ammo moves up. Also, Enemy Ammo can hit the
Spaceship and Spaceship Shield sprites, but Spaceship Ammo can hit enemy sprites. More
interesingly, Enemy Ammo, contrary to Spaceship Ammo, is level-aware: it changes the
costume based on the current game level. Due to the similarity between Enemy Ammo and
Spaceship Ammo, the Enemy Ammo scripts are included in the starter project.
Engage thrusters
When the game starts, the Spaceship Ammo sprite will only iniialize its variables but not
paricipate in the game yet.
To create the code to iniialize upon receiving the game_start message, perform the
following steps:
1.
Start with the when I receive <game_start> block.
2.
Use set <speed> to () ; fill in the value 100 .
3.
Use set <power_boost_on> to () ; fill in the value false .
The final script should look like the following screenshot:
The following steps create the code for each Spaceship Ammo clone:
1.
Start with when I start as a clone .
2.
Add the go to <Spaceship> block.
3.
Then add the go to front and show blocks.
4.
Add a bit of zest with play sound <laser> .
5.
Add an if () then () else condiion block to check whether the power_boost_on
condiion is true .
6.
If power_boost_on is true , this ammo can destroy muliple enemies. So it uses the
change y by (<speed> * <frame_rate>) and repeat unil <y posiion> is greater than
() blocks; fill in the value 180 in the repeat unil block.
 
Search WWH ::




Custom Search