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.
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...
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.
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.
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.
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...
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.
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.
Finally add a script to the gun sight so that it is always where the mouse pointer is...
... and name the sprite "gun sight".
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.
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!
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.
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.