Code a Christmas Game ... with Cats!

Code a Family Christmas Game …With Cats

Ryan Brewer Community, Tutorial Leave a Comment

‘Twas the night before Christmas, when near and within the tree,
Lay a fallen Star Topper …and sounds of rustling!”

Recommended ages: 7+ w/parent
Completion time: ~30 minutes, plus optional drawing time

What You’ll Make

You’ll create a game for you and your family.

Play as the Christmas Tree Star, who’s been knocked off the tree by the (crazy) house cat. Like every Star, you’re far from helpless. You’ll jump your way back to the top. But beware! The (truly crazy) cat is still inside the tree …with black eyes open wide …hunting you.

Getting Started

  1. Go ahead and play a quick round of the finished game. You’ll click the green flag to start the game.
  2. Create a Scratch account. (There isn’t an age requirement, but you will need an email address. Politely ask a parent for help!)
  3. Follow this link to the Tree Topper vs. Crazy Cat Starter Project page and click the green Remix button. When you Remix a Scratch project, you’re just making a copy for yourself.

You should now see something like this:

Overwhelmed by what you see?
Click the Tutorials button at the top of the page, and watch the Getting Started video.

Real Star Power

Ensure the Star sprite is selected…

Jumping Power

GIVEN the game is playable, WHEN the spacebar is pressed THEN the Star jumps
  1. Drag the “if playing” block under the “when space key pressed” block to connect them. We’re setting things up so the spacebar only does stuff while someone is playing–and does nothing when the game is over.
  2. Connect the blue Glide Block below our last Purple block. These four blocks will be our “jump.” The glide block is enough to do this. But since we’re literally a Star, we’re adding some pizzazz by crouching first.
  3. Move our 4 connected blocks inside the “if playing” block. To move a group of connected blocks, grab them by the block on top (the purple one). See the picture below.

Now read the whole block back to yourself. It isn’t perfect English, but it is readable! “When the space key is pressed, if the game is being played then crouch for a short spell, stand, and glide! AKA Jump!”

Having trouble following along?
Try using the pictures instead!

Did you Know?
The GIVEN, WHEN, THEN style of describing our game is popular amongst bonafide software engineers!
Confused by the Glide Block?
Tinker with it! Change each of the numbers in it, but just one at a time. Play the game after each change. How does each one affect the jump?

The Power to Win

GIVEN the game is playable WHEN the Star reaches the top THEN end the game
  1. We have two blocks left. Grab the light blue “touching mouse-pointer” block and drop it into the pink “End Game If” block.
  2. Change “mouse-pointer” to “edge”
  3. Drag the pink block inside the “If” block, so it’s the last one inside.

Crazy Cats get Written Up

It’s time to write code for that cat. Click the Cat Sprite to select it.

Cats Prefer Stalking to Stockings

WHILE someone is playing THEN the Cat Hunts

Noodle on that for a second. Can you figure out which two blocks can make that happen?
Micro hint: they’ll connect to the “when I receive start game” block.

  1. Attach the “repeat until” block to the “start game” block.
  2. Drag the pink “hunt” block inside the “repeat until” block.

Say Bah Humbug Without Saying Bah Humbug.

GIVEN the Cat can hunt the Star, WHEN the Cat finds the Star THEN it Attacks

Can you fit the rest of the blocks together just by reading the statement above? If not, follow the next steps.

  1. Attach the “if cat found the star” block below the “hunt” block, but inside the “repeat until” block.
  2. Drag the pink “attack” block inside the “if” block.

Now that the Cat can hunt, read the blocks back to yourself. Just like our Cat, it’s (somewhat) readable! “When I–a most amazing cat–hear that a game has begun, so long as someone is playing this game I can Hunt the helpless little Star, and bat it from my tree.”

Put a Bow on It

Make this game your own. Draw your own Star and Cat!

Draw your own Star

  1. Select the Star character
  2. Go to the Costumes tab
  3. Select “My Stand” and draw your star, standing
  4. Select “My Crouch” and draw your star, crouching
  5. Go back to the Code tab and change the Costume Blocks to use “My Crouch” and “My Stand”

Try to make your standing and crouching Stars roughly the same size as mine. You don’t have to be exact.

Draw your own Cat

Follow the same steps as you did for the Star. To find the purple costume blocks, scroll to the right. See them? They’re under the Cat’s “Attack” block!

That’s a Wrap!

You may have noticed we didn’t code all of the features, like the Timer or the Introduction (when the Cat knocks the Star from the top of the tree). I hid these since they were a bit too complicated for this tutorial.

One of my favorite ways to learn to code is to tinker, so go ahead and play around! You can save copies of your project by clicking File, then Save as copy.

Enjoy your game! And have a very Merry Christmas!

Side note: If getting paid to write blogs in your free time is something you’d enjoy, check out our Careers page. It’s an exciting time to join the Keyhole team, and we may just have a spot for you!

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments