Homeschool Math with Scratch

Created on August 23rd, 2014. Built on the MacBook Air.

Devon hasn’t been as interested in Scratch lately, so we haven’t been building any new games. He did, however, just start kindergarten. We’re homeschooling, and I figured since he has to learn his math anyway maybe we could create a game for him. He wasn’t very interested in building it at first, so I told him I would do it and as soon as I started building it, he jumped right in and wanted to help type out the variable names.

I started with a google image search and imported the image to create a sprite of numbers:


The first version of the game was kind of silly in that I made a sprite out of each number and each sprite stored its own value. As with most programming, I generally try to get a working prototype first and then go back in and refactor it once I’ve proven the concept. The final version of this game comes complete with a displayed answer and much less complexity and duplicated code.

Once I changed things up, it was helpful to export the costumes as individual images (which I used the editor to obtain):


Here are the sprites for the left hand number, right hand number, 10’s place answer, and 1’s place answer:


Each sprite contained all of the numbers as costumes, named accordingly so we could access them via code:


Here’s the main stage code using variables for left, right, and answer:


The code for the left and the right is pretty straight forward, the only different being the variable we use to display the costume (either left or right):


Displaying the answer gets a little more tricky. You have to think about the one’s place and the ten’s place differently. I coded it this way in case I want to add more complex answers in the future beyond 18 (that’s the highest number you can currently get out of this):



The mod function wasn’t working as I thought it would, so I had to put in some test variables and display them on the screen to figure out what was going on. As with all programming, it’s really important to view the data and not make assumptions.

It would be easy enough to add other math functions to this such as subtraction and multiplication. You could add a menu and then just change out the functions used and the stage costume which currently shows addition.

This was a fun way to spend a bit of time on Saturday. I hope it gets you thinking about creative ways you can build tools to help educate your kids.

Here’s a demo:

Here’s the full Scratch file: Counting Refactored


Helicopter Fighter Game

Created on July 13th, 2014. Built on the MacBook Air.

I have some games on my iPhone Devon loves to play. One of them is called Heli Hell:


Devon had the idea of building a version of this game in Scratch. It sounded like a fun challenge. Devon really likes this one and has some further ideas for it including building out what he calls a giant spike ball coming out from the helicopter which another player can control to attack the bad guys. I haven’t quite figured out how we’ll make that work, but for now wanted to show the progress we’ve already made.

I haven’t yet added a fancy start or game over screen, so the stage code is pretty simple:


For the helicopter, I used the same trick we learned last time when building the helicopter fire fighter game. You simply rotate through two costumes which makes it look like the helicopter blades are spinning:


And here’s the code:


The sprites used for the game, including some islands to give the impression the helicopter is flying forward:


The bad guy code is pretty interesting. It follows a pattern of moving left to right and back again until it reaches the bottom of the screen. It’s also in a loop so when its done, it will announce another ship to appear. The ship appears after a random interval and it fires its weapon between 2 and 7 seconds later (a number we had to adjust as the game started out being too difficult for Devon).


And here’s the bad guy weapon:


The helicopter can shoot back with its own bullets. They both follow a similar pattern:


If the bad guy’s lives run out, it releases three coins which each increase the player’s score when they are collected:


To create the illusion of flying forward, these islands all have similar code with the only difference being the names of the announced events.


We could add a lot more to this game and fancy it up a bit as well, but for now it works and Devon has a lot of fun playing it. The “spike ball” may come later. 🙂

Download the Helicopter Fighter Scratch file and enjoy!