Introduction: Coding Your First Video Game BalloonPop

Have you been curious about coding, but you are not ready to sign up for a big investment in time? This is a shortcut to make your first video game. Follow these steps and you will have a (very) simple game, which you can make more complicated later.

This instructable is focused on "What to do", with very little information on "Why" for each step. This makes it faster than some other instructions. If you want to understand the "why", the book listed in Step 11 is excellent.

If you want to play the game, before you learn how to create your own, then click here and use the mouse to pop each balloon before it can escape through the top of the screen!

BalloonPop1Lesson on Scratch (mit.edu)

Supplies

·       Laptop or tablet, with a mouse

·       Internet connection

·       Email address

Step 1: Register to Create an Account

a.     Go to the Scratch home page. Scratch - Imagine, Program, Share (mit.edu)

b.     This step will require an email account, but it will not require a credit card.

It is important to register, so you can save your work, and so you can allow other people to play your game (if you want to allow them).

Scratch saves your work in the cloud, not on your local laptop.

c.     Click on the target on the upper right side of the screen, where it says "Join Scratch", to create an account. Remember your user name and password, so you can sign in again later.   

Step 2: Create a New Project

Near the top of the page, on the left side, click on “Create” to start a new project.

You can give it a name here. Later, you can "Share" your project, if you want others to be able to play it.

Step 3: Learn the Screen Areas

These are the names of the areas on the SCRATCH screen, which we will use in the next steps.

Step 4: Select Balloon Sprite, Starting Score = 0, How Many Balloons.

Eliminate the tutorial and hide the Scratch cat.

Select the “Balloon” so we have a sprite to work with.

Make a variable called “Score” and set it to zero at the start of each game.

Grab a loop, to be used soon, so we can have 10 balloons in our game (one at a time).

Step 5: Balloons...where to Start?

We want each new balloon to appear at a random x position (left / right) and at the bottom of the screen (y= negative 180 = -180)

Step 6: Make Balloons Float Up

We will tell the balloons to change y position, in a positive direction, so this means they will go up on the screen. There are 360 steps from bottom to top. In the example, we tell the balloon to move 10 steps on every jump, and to make 48 jumps. We use 48 jumps so there is a little bit of time between one balloon disappearing and the next one appearing at the bottom of the screen. You could use different combinations of steps per jump and number of jumps.

If you select the green flag, you can watch the balloons. You cannot pop them yet, but you can try different combinations and watch the different speeds.


Step 7: Check the Score

After all 10 balloons have been launched, it is time to check the score.

  • If the score is above the number we select, then the player will be rewarded with a short song.
  • If the score is NOT above the number we select, then there will be a “Game Over” message.

Step 8: Make the Balloons "poppable"

Start a new script, to be activated when the balloon sprite is clicked. When this happens, we do three things:

  1. Increase the score.
  2. Play a “pop” sound.
  3. Hide the balloon, since it has been popped.

Now, you are ready to play your game (green flag)! If it does not work, you can compare your script to the one shown in step 9.

Step 9: Compare Your Code

Compare your code to this screen capture. The comment blocks, on the right, are to help you understand. They are NOT required, for your script to run.

Step 10: Enhancements, Bonus Times Table Game

Enhancements

a.     Click on the right side of the screen, to add a backdrop or a “stage” for the balloons.

b.     Speed up the game, or slow it down, by making changes in the loop for “Change y by …”.

c.     Change the score required for the victory sound.

a.     Make the score required smaller so the player will get the victory sound easier.

b.     Make the score required more than 10, and they will never win, since there are only 10 balloons! (I might pull this trick on my sister, but please don’t tell her!)

BONUS: This script has been edited to create a “Times Table” practice game, where you can practice your multiplication tables. It is playable by clicking this Balloon Times Table on Scratch (mit.edu) . If you "look inside" you may learn more about Scratch.

Step 11: Credits

Credits:

·       This instructable was inspired by: Book: Super Skills: Learn How to Code in 10 Easy Lessons by Sean McManus

·       His version of the game is found at: Balloon Popper-2 on Scratch (mit.edu)

There are many tutorials and other ways to learn more about SCRATCH. I hope you enjoyed this introduction to coding.