Basics: Shooting

Watch the movie
Step 1. Draw the stage
Step 2. Create 3 sprites
Step 3. Make the cannon move
Step 4. Make the shot shoot
STep 5. Make the target explode

Watch the movie

Watch the movie below to see a cannon that shoots. When you press and hold the mouse button, the cannon points in the direction of the mouse cursor. When you press spacebar,  the cannon shoots. When you hit the target, the target explodes.

Step 1. Draw the stage

Here’s a picture of the stage background. Notice that the cannon’s mount is part of the stage. Have fun making something similar!

Step 2. Create 3 sprites

You’ll need 3 sprites: the cannon, the shot, and the target. Make sure that you give your sprites the same names that they have in the picture below:

The target sprite has 2 costumes, like this:

When you create the cannon, it might be helpful to watch the movie below. The movie shows how to set the costume center of the cannon so that it rotates in a realistic way.

Step 3. Make the cannon move

When the mouse button is held down, the cannon always points in the direction of the mouse pointer. Can you assemble the commands below to make that happen? You’ll need to change the order of the commands and the numbers or options!

Step 4. Make the shot shoot

The script for the shot sprite requires a few steps.

When the green flag is clicked, the shot sprite hides. Can you add the appropriate command to the shot script?

Then…

When the spacebar is pressed, the shot sprite…

  1. goes to the cannon
  2. points in the direction of the cannon
  3. shows itself
  4. moves continuously until it reaches either the edge of the screen or the target
  5. hides again

Step a is pretty simple and involves just one command. You’ll need to use its drop-down menu to make the shot sprite go to the cannon sprite.

Step b has a trick! You can combine the two commands below to make the shot sprite point in the same direction as the cannon. Can you find these commands in Scratch and configure them properly?

Step c requires adding one, simple command. Can you find it and add it?

Step d is the most complicated, so let’s look at it closely. In Scratch, to make an action repeat until something happens, you use the following command:

Here are all the commands you’ll need for Step d. How do you think you should assemble them so that the shot moves continuously until it reaches the edge of the screen or the target?

Step e requires adding one, simple command. Can you find it and add it?

Finally, here are all the commands you to make the shot shoot when the spacebar is pressed. You’ll need to repeat one of them. Can you assemble them correctly?

Step 5. Make the target explode

Here’s the last step! When the shot sprite reaches the target, the target should explode! Here are the commands you’ll need. Can you unscramble them properly?

 

. . .

That’s it! Have fun!