Introduction: 2D Shooter Scratch Game
In this instructable, I'm going to be showing you how to make a 2D shooter scratch game. It is pretty simple to make, but hopefully, you'll learn some things along the way, and soon make your own scratch games!
- A Computer.
- A Scratch Login/Account.
- A Mouse (Makes playing the game when you are done much easier).
Step 1: New Project
The first thing that you want to do is go to https://scratch.mit.edu/. Then you want to sign in with your account and click "Create".
Step 2: Making a New Sprite
The first picture is what you should see after clicking the create button. What you want to do now is click on the scratch cat icon that says "sprite one", and then click on the trash button. This will delete the starting sprite so that we can make our own. Next, we want to click on the cat logo with the + sign, and then select paint. Now we can make our first sprite.
Step 3: The Main Character
Now we want to make our main character, which the player will control. Using the tools on the left, make a small circle that is centered in the middle, and use the line tool and rectangle tool to draw arms and a gun. You can get experimental with the colors if you want to, but for the first time, just try to make it as similar in size and shape as mine. Finally, once you are done, click on the text where it says sprite one and replace it to say "Player", as mine does. This is just a way for us to know that "Player", is referring to our main character.
Step 4: The Bad Guy
Now that we made our main character, we need to make something for that character to fight. Using the tools on the left, once again, make the same thing as in step 3, but with more straight arms and no gun. Make it about the same size as "Player", and make sure that is facing directly left. Finally, rename it as we did in step 3 to something like "BadGuy". Before we move on to the next step, click the backdrop icon at the bottom left and select paint.
Step 5: The Background
Once you've clicked on the paint icon from step 4, use the rectangle tool to make a background out of the color of your choice just like how you drew the sprites. Make sure to delete the blank white background that is automatically made for you, so that the only background you have is this one. Then finally, name it to something like "Background".
Step 6: Game Over Background
Clicked on the paint icon again and make a second background using the text tool to make something that looks like this. Rename it to GameOver, or something similar, and move on to the next step.
Step 7: A Bullet
Now we are going to make a bullet that our player can shoot at the bad guys. This is even simpler than the other sprites, and all you have to do is make a small horizontal rectangle, centered on the plus sign in the middle. Then name it "Bullet", and go to the next step.
Step 8: Coding
First, select the "Player" Sprite form the bottom left corner that we made before. Then, at the top left corner where it says code, costumes, and sound, click on code. You can scroll up and down through the color-coded blocks, and drag and drop blocks onto the workspace. To delete a block, drag it back to the left side. Get used to moving, detaching, and deleting blocks. By looking through the code blocks, recreate the code in the picture. When you get to the "Broadcast" block, you are going to make a new broadcast, and name it "Shoot", and then select it in the block's built-in the dropdown menu.
This code is doing is allowing the player to move with WASD (up, left, down, and right). It is also starting the sprite in the middle of the screen. The right piece of code is going to be how we get the bullet to shoot. If you don't understand any of this, that's okay, just copy the code, and see if you can figure out how it works along the way.
Step 9: Shooting
Once again, as in step 8, you are going to recreate the code in the picture, but on the bullet sprite (click on the "Bullet" sprite at the bottom right).
This code works with the code on "Player", and makes it so that whenever the mouse is held down, it creates a clone of the bullet (allowing there to be multiple bullet sprites at once) in front of the player so that it looks like it is coming out out of the player's gun, and then moves in the direction that your mouse was pointing. This gives the person playing the game the ability to aim and shoot bullets.
Step 10: The Bad Guy Code
This is probably the most complicated and crucial code yet. Select the "BadGuy" sprite, and then make sure that everything is like the picture. In this part of the code, we need to make a variable. We do this the same way that we made the broadcast message. Make sure that "for all sprites" is selected also. We also have to make a second broadcast message called GameOver.
This code makes it so that the bad guy makes clones that spawn randomly at the edges of the screen. It also makes it so that the bad guy is always following the player, dies when a bullet hits it, and that the game ends when one of the Bad Guys touches the Player.
Step 11: Final Steps
Finally, add the Code in the left picture to the "Player", the code in the top right picture to the "Bullet", and the code in the third picture to the "BadGuy". This is how we stop everything from happening once the game is over and end the game. You did it! Double Check that everything is coded correctly. Click on "See project page" at the top and go play your game! Click the green flag to run the code and the red stop sign to stop the code. If you want to see the one that I made, or double check your code, go here: https://scratch.mit.edu/projects/381823733/. Feel free to add new things, like high scores, health, damage, and different guns. Have Fun!
5 People Made This Project!
- 353200017 made it!
- kiD made it!
- caleb.deathkitten made it!
- hsheets1508 made it!
See 1 More
Question 15 days ago on Step 8
how to make cats on initial blocks?
4 months ago
the bullet is so slow
1 year ago
Cool! I'd love to build it.
2 years ago
That is a cool game. i am now working on some code for a scoring system for it!
2 years ago
2 years ago