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 build the 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 programming and for the development of problem-solving skills.
Scratch Game: Knight collects the coins in the Castle
Play the game
To win the game, the player must 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 first, you lose. Let’s build the game!
Building the game
Let’s break the project down into a series of steps to build the game:
The knight sprite’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, its motion will start when the green flag is clicked and continue forever! This sprite also moves randomly around the screen.
Coin sprites are how the players 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 to different positions on the screen.
4. Money Pouch
The money pouch sprite works the same as the coins, however, instead of only increasing the variable “Money” by 1, it increases “Money” by 5. You can draw your own sprite for this.
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, this happens when the knight touches the ghost.
For a more detailed look at this game, check out our lesson plan slideshow!