How to Code a Basic Retro Space Shooter on Scratch!

by hmartin22 in Circuits > Computers

615 Views, 4 Favorites, 0 Comments

How to Code a Basic Retro Space Shooter on Scratch!

IMG_4624.jpeg

Hi I have created this tutorial for people who are new to coding on scratch and would like to create a game.

Below this is me playing the game.

Supplies

For This You will need to have or make a scratch account to create and save these games.

Creating the Background

IMG_4599.jpeg
IMG_4600.jpeg

First Go to the background tab at the bottom of the screen, Click it then convert to bitmap. Use the bucket to fill it with black and then add white dots. Note: you can animate it but that is optional.

Add a Ship

IMG_4601.jpeg
IMG_4602.jpeg

To add a space ship I Set my pen size to 5 on bit map to make it a pixel and made something that looked like a rocket. I also decided to add a spinning animation.

Aliens!

IMG_4609.jpeg
IMG_4610.jpeg

Now for the fun part Design an alien That the ship has to defeat to get points. For my alien I decided to make it spin to make it look cooler

Add More Aliens and Delay Animations for Wavelike Pattern

IMG_4610.jpeg
IMG_4611.jpeg
IMG_4614.jpeg
IMG_4612.jpeg
IMG_4613.jpeg

For this step you add a block that says go to and set the start location and then get the glide to block and set were you want it to go. Then add multiple aliens with the same script and add a short 0.1 - 1 second delay adding a tenth or more seconds each time this should result in a wavelike pattern if done correctly.

Laser Beam

IMG_4616.jpeg
IMG_4617.jpeg
IMG_4618.jpeg
IMG_4617.jpeg
IMG_4619.jpeg

Create a beam out of pixels any design you want then make it hide when flag clicked but when space key pressed show go to the space ship whatever sprite it is and change y by 20 until it hits the alien or make it wait 3 seconds and then hide.

Score and Alien Hit

IMG_4622.jpeg
IMG_4623.jpeg

Make 2 new variables one called hit and one called score. Make it so when the flag is clicked these two variables are set to zero. Go to all of the alien sprites and make have a forever block around an if then block which says if touching laser beam (what ever the sprite is called) then change hit and score by one. Now code it so when hit equals three make the aliens show and then make it so when hit equals six show a new sprite which is your YOU WIN! screen.

The End

That is all there is to making a shooter game

If you would like the rocket to move then do when key left or right pressed then move -10 or 10 x Eathier direction