Download presentation
Presentation is loading. Please wait.
1
Creating a Tank Game in Scratch
2
Importing a Sprite Firstly, create a new sprite by selecting “paint new sprite”. In the window that appears, press “import” to select a sprite to add to the project. Import the base of your tank, and it will appear on the stage.
3
Scripting the tank To make the tank move, you’ll need to add a script. Click on your sprite to select it, then go to the “Scripts” tab. Add the script shown below so that when the arrow keys are pressed, the tank moves. If the tank is not facing in the right direction when it moves, edit it and rotate it 90⁰
4
Importing the gun Now that the tank can move, the gun can be added. Create a new sprite and import the gun sprite. Select “Set Costume Centre” and set it to the centre of the gun. You may have to rotate it 90⁰. Add the following script to the gun, so that it follows the mouse pointer and stays on the tank base.
5
Creating the crosshair
The next thing is to create a crosshair so that the player can see where they are aiming the mouse. Add a script to make the crosshair sprite always follow the mouse pointer.
6
Adding ammunition Create a new sprite and draw a projectile for the tank to shoot. Go to the “Costumes” tab and import each frame of the explosion animation.
7
Scripting the ammunition
Add a script for the ammunition sprite. When the gun is not being fired, the tank shell does not need to be visible. Use “show” and “hide” to toggle between the two. When the space key is pressed, the shell needs to face towards the crosshair and move towards the crosshair. Then, the costume needs to be switched 9 times, as there are 9 frames in the explosion animation. Finally, the shell is hidden again.
8
Scripting the ammunition
Finally, import a background and try out the game!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.