Sort of story telling thing

This guide has been design to help you create a simple game. Follow these step-by-step instructions to create an interesting set of effects.

Use the left and right keys as well as the mouse to keep your tank safe.

Stage 1 - Making the tank

Start a new Scratch project - "File" and then "New"

Making the tank involves using the imported graphics.

Open the folder Student common \ ICT \ _Year 07 \ Topic 5 Scratch challenge \ Tanks

You will need this folder more than once so keep it open.

Drag the tank body onto the cat and let go. the cat will become the tank body.

Click on costumes ...

,,, and remove the cat costumes.

Stage 2 - Making the tank move

In the same way we made the girl move in project 3 we can make the tank move...

... however the tank does not move like a tank should so start again.

We will use the up arrow to set the speed and the left and right arrows to steer the tank; like this...

... strangely the tank will move in a peculiar fashion and turn in an equally non-tank like way.

The first part of the solution is to make sure that the sprite is centred correctly. Edit the tank costume and click on "Set costume center" (Don't you just love American spelling mistakes). Move the cross hairs so that they are centred on the middle of the tank. Press "OK"

Next you will notice the the tank sort of crabs sideways rather than drives in the direction it is pointing.

In thie image below I have highlighted the icons that you can use to turn the sprite left and right and I have highlighted the little image that shows the direction of movement of the sprite. You need to rotate the sprite so that the irection of movement is the same as the direction the tank is facing...

...like this.

Now the tank moves more like a tank should; it does move and turn a little quickly so change the script to make it slower, like this.

Stage 3 - Adding the turret

You could add the turret by adding a new sprite from a file or you can add a surprise sprite and then drop the turret on top.

So "get a surprise sprite"...

... and then drop the turrent on to the top of it. My surprise sprite turned out to be a carpet but the next step is to delete it as a costume, just leaving the turret.

Much quicker.

Again you have to align the turret correctly so that it will turn and point as you will want it to do.

Edit the turret costume and make the turret point the same way as the blue line (use the right and left icons) ...

... and then use "set costume center" to put the cross hairs on the centre of the turret; one of the cross hairs must go down the centre of the barrel.

Stage 4 - Adding the turret to the tank

Firstly have you noticed that I have changed the names of teh sprites to be "tank" and "turret"? This makes some of the code easier to understand and to write.

Next, we need to add a script to the turret to make it point at the mouse pointer...

... and then use the "goto sprite" block to make the turret stay on the tank.

Try it an you will see that as the tank moves the turret will stay as part of teh tank and it will always point at the mouse-pointer.

Stage 5 - Adding the gun sight

The first thing to do is to "paint a new sprite" ...

... which is to be a gun sight, a circle and a cross; just like the one in the picture below...

... then using the "set costume center" option centre the cross hairs on the exact centre of teh gun sight sprite.

Then make the sight smaller to fit into the game. (Right click on the gun sight sprite.)

Finally add a script to the gun sight so that it is always where the mouse pointer is...

... and name the sprite "gun sight".

Stage 6 - Making the projectile

Again, the first thing to do is to "paint a new sprite", zoom in using the zoom controls that I have highlighted and draw a sort of bullet shape...

... and press "OK".

The next step is to work out what heppens when the projectile is fired in terms of the sprites that are already created.

In effect the projectile starts of at the turret and flies to the x y coordinate of the gun sight. How can this be done as a script for the projectile?

Firstly add a "goto " block and make the projectile go to the turret...

... then it needs to "point towards" the gun sight...

... then it needs to glide to x y where x and y are the x y position of the gun sight.

one of the sensing blocks will tell the projectile what the x or y coordinate of the gun sight sprite...

... so this can be added to the script. Note that I have shrunk the window for the outpus so that the script window is big enough to see all the script.

Try it and see that the projectile now takes a second to get from the gun to the target, although at the moment noting happens when it gets there.

Stage 7 - Making the explosion

Ah, an explosion! This time you will make use of the fact that scratch can change costumnes quickly to make the projectile explode.

Add all of the explosions from the "Tanks" folder to the projectile sprite; just drag them and drop them onto the sprite.

There are now 10 costumes for the projectile, the original bullet shape and the 9 explosion images.

Now edit the script for the projectile.

At the start the projectile sprite must be hidden and it must be the bullet shape - the first 2 blocks.

Then there is a repeat 10 loop (10 because there are 10 costumes) that changes to the next costume.

Finally the projectile is hidden from view.

Try this and see if it works like this!

 

Stage 8 - Adding terrain

This is easy enough. Switch to the stage and then background as in previous projects) and drop the "ground" from the "Tanks" folder onto the project.

Stage 9 - Extension

Add a car moving through the ground for the tank to shoot at.

Go back to the race game and add the explosion to the race ar so that it looks even better.

Recent Posts

July 24

Repairing a hyperspace window

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem. Phasellus quam turpis, feugiat et sit amet ornare in, hendrerit in lectus semper mod quis eget mi dolore.

July 18

Adventuring with a knee injury

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem. Phasellus quam turpis, feugiat et sit amet ornare in, hendrerit in lectus semper mod quis eget mi dolore.

July 14

Preparing for Y2K38

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem. Phasellus quam turpis, feugiat et sit amet ornare in, hendrerit in lectus semper mod quis eget mi dolore.

Spotlight

Neural Implants

The pros and cons. Mostly cons.

Phasellus quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat ornare in, hendrerit in lectus semper mod quis eget mi quat etiam lorem. Phasellus quam turpis, feugiat sed et lorem ipsum dolor consequat dolor feugiat sed et tempus consequat etiam.

Lorem ipsum dolor quam turpis, feugiat sit amet ornare in, hendrerit in lectus semper mod quisturpis nisi consequat etiam lorem sed amet quam turpis.