Sort of tank shooting Game

This guide has been designed 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 share / Department\Computing / _2017-2018 / KS3 / Year 8 / 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.

1. Screenshot your project so far and describe how you changed the cat sprite into the tank sprite.

 

Stage 2 - Making the tank move

In the same way we made the girl move in project 3 we could 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 the 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 direction 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.

Screenshot your project so far and describe importing the tank body sprite and maing the tank sprite move.

2. Screenshot your project so far and describe how you made the tank move.

 

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 turret 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.

3. Screenshot your project so far and describe how you made the turret face the right way.

 

Stage 4 - Adding the turret to the tank

Firstly have you noticed that I have changed the names of the 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 the tank and it will always point at the mouse-pointer.

Screenshot your project so far and describe adding the turret sprite to the tank sprite so that they move together as a single sprite.

4. Screenshot your project so far and describe how you added the turret to the tank.

 

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 the 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".

Screenshot your project so far and describe adding the gunsight sprite.

5. Screenshot your project so far and describe how you made the 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 happens 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 outputs 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, nothing happens when it gets there.

6. Screenshot your project so far and describe how you made the projectile.

 

Stage 7 - Making the explosion

Ah, an explosion! This time you will make use of the fact that scratch can change costumes 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!

7. Screenshot your project so far and describe adding explosions to the game.

 

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.

8. Screenshot your project so far and describe how you added terrain to the game.

 

Stage 9 - Extension

You will have noticed that there are traffic cones in the graphics folder. Add a number of these at random to the game and add a script to that the game ends if the tank touches one. The tank can of course shoot the traffic cones.

Add solid objects for the tank to drive round such as small houses (Easy to draw, a rectangle and 5 lines with a shaded fill)

Add a scoring system, add points for hitting cones and deduct points for hitting houses.

Make the houses about the same size as a tank, maybe a little bigger.

9. Screenshot your project so far and describe how you made the game more complicated.

 

Year 8 Extension

Add a car moving through the ground for the tank to shoot at. The car should avoid the houses and cones.

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

10. Screenshot your project so far and describe how you added terrain to the game.

 

Recent Posts

May 24

Repairing a hyperspace window

You may have noticed the time shift in the Blue coridor, there is a redshift at certain times of the day; this has caused the bells to malfunction and the PCs are runing slow as the server room is also moving ever so slowly into the 5th dimension. The Lightspeed engineers are working hard to fix the hyperspace window being generated by the tidal effects of big data and the weaknesses in the walls caused by excessive data mining. Cambridge Analytica's data scraping has also contributred to the weakness in the space time continuum. There is no need to be afraid as everything is should be resolved in the near future; nevertheless steps are being taken, mostly from the gold staircase.

Any further information will be included here when and if we get it.

July 18

Adventuring with A GDPR SUrveyor

The GDPR surveyors will be in the College in the near future checking that you understand your obligations under GDPR. Are you aware of the consequences? Do you know who knows about you? Do you know what the people you don't know about, know about you? Have you checked your own settings? Are you privacy minded? The GDPR surveyors will check. They know you, possibly better than you do but maybe not as well as the Internet knows you.

July 14

Games for Free

There are a number of games that you can get for free that are really good. They are really good at collecting all of your data and passing it on to someone else. You don't know who they are and you don't know why they are collecting your data. They have your data and access to your friends. In minutes they have your friends' data and are collecting the data from their friends. If its a good game you will even tell your friends about it so you do their sneakiness for them and still tell your friends. It will never happen to you but hey that game...

Spotlight

Neural Implants

The pros and cons. Mostly cons.

Be permanently connected to Google and you can ask Alexa in your head; only you can hear the answer...