Knight Collects the Coins in the Castle
Scratch is a versatile, online program that can be used to teach several important skills as well as maintaining a level of fun and engagement through the use of game and animation creation. Today, we’ll focus on a game called Knight collects the coins in the castle, which you can find here. This game is fun to make and play and uses concepts like x and y coordinates, sensing, decision making and variables. These are important skills, both for computer programing and for the development of problem-solving skills.
The aim of the game is to collect all the coins and money bags before the ghost catches you. If you collect all the coins and the money bag, you win. But if the ghost touches you, you lose. Let’s build the game!
Let’s break the problem down into a series of steps to build the game:
The knight’s motion is controlled by using the arrow keys. Creating functioning arrow keys is an important part of Scratch as many games rely on this for the movement of sprites. This helps to establish coordinate systems, as well as reinforcing the concept of negative numbers when we want to move left or down (negative on the x and y axis).
The ghost sprite is automated, and therefore we won’t be controlling it. Instead, it’s motion will start when the green flag is clicked and continue forever! This sprite also moves randomly around the screen.
The coins are the way that players can score points. To create a point scoring system, we need to use variables. We can assign a variable any name we want, for example, this one can be called “Money”. We only want the “Money” variable to increase when the knight is touching a coin. We can use sensing to achieve this. So now, when the knight touches the coin, the variable “Money” increases by 1 and then the coin disappears. We can then duplicate the coins and assign them different positions on the screen.
4. Money Pouch
The money pouch works the same as the coins, however, instead of only increasing the variable “Money” by 1, it increases “Money” by 5!
5. You Win backdrop
The You Win backdrop will show when we have collected all the coins and the money bag. Therefore, our code needs to reflect that. Using conditionals, we can make sure that the backdrop will only change if our variable “Money” is equal to the total amount of “Money” you can get in the game.
6. You Lose backdrop
The You Lose backdrop is similar to the You Win backdrop, however, it only happens when the knight touches the ghost.
For a more detailed look at this game, check out our lesson plan slideshow!