Book Image

Scratch 2.0 Game Development Hotshot

Book Image

Scratch 2.0 Game Development Hotshot

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Game Development HOTSHOT
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Adding scripts to Spaceship Ammo and Enemy Ammo


The Spaceship sprite fights enemy sprites with Spaceship Ammo, and enemy sprites attack with the Enemy Ammo sprites.

Prepare for lift off

Spaceship Ammo has one local variable, speed. The speed variable is how fast this sprite moves. Upon creation, it flies out of the Spaceship sprite and moves straight up until it hits an enemy or the top edge of the Stage.

The Enemy Ammo sprite is very similar to the Spaceship Ammo sprite and is different only in direction, hit target (the sprites it can hurt), and costumes.

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 interestingly, 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...