Step 1: X-Wing Starting Code 1

Goal:


As with all Scratch projects, we need to have a way to activate certain code when the game begins, and we do that by using the “when green flag clicked” block. This will start running and code we have attached to it as soon as you start your game.

We also need to create a variable that will tell our X-Wing how fast it needs to move.

A variable is something that holds a piece of information that we can use many times in our code.

Our variable speed will hold the number that tells our X-Wing how fast to move.

Lets go ahead and get started on programming out X-Wing.

Steps:

  1. From the sprite menu click on the on called X_Wing.
  2. From Events, place a when green flag clicked block.
  3. In Variables, click the “Make a new Variable” button.
  4. In the Window that appears type “speed”.
  5. From Variables, place a set to block.
  6. Set the variable to speed and the amount to 5.

Code:


Click to replay