We will learn how to create a game concept and use Scratch programming to turn it into a fun and interactive game. Our game concept will be called “Jumping Chicken”, and we will learn how to use programming concepts such as event handling, randomization, coordinate manipulation, movement, gravity, and scoring to make the game challenging and engaging.
In this unit, we will start by brainstorming a game concept and planning out the game mechanics, such as the main character, obstacles, and scoring system. We will then learn how to use the “when key pressed” event to control the game, how to add randomization to make the game more unpredictable, and how to manipulate coordinates to move sprites around the screen. We will also learn how to add gravity to the game and make the game more challenging by adding obstacles and scoring.
Throughout this unit, we will focus on creativity, problem-solving, and computational thinking. By the end of the unit, you will have created your own game concept and turned it into a playable game using Scratch programming.
“Welcome back to Scratch programming with a fun project! Before we start making this project, we need to learn about loops first.”
Loop programming is when we tell the computer to do something over and over again. It’s like asking a friend to count to 10, and instead of counting one number at a time, they count all the way up to 10 without stopping.
In programming, we use loops to repeat a set of instructions or actions. We can tell the computer how many times we want the loop to repeat, and it will keep doing the same thing until it reaches that number.
Let’s say you’re using Scratch to make a ball move to the right. You can make it move 10 steps by clicking on a special block. But if you want it to move more than 10 steps, you’ll have to click on the block many times! That can be tiring. Instead, you can use a special command called a “repeat” loop. This will tell the computer to make the ball move to the right multiple times automatically, so you won’t have to click as much.
That’s basically what a loop is in programming – a way to get the computer to do something repeatedly without us having to type out every single step.
Repeat loop and forever loop
Today we’re going to learn about two types of loops in Scratch that can make our games more fun.
The first type is called a “repeat” loop. This loop helps us repeat an action a certain number of times. For example, if we want a character to jump 3 times, we can use a repeat loop and tell it to jump 3 times.
The second type of loop is called a “forever” loop. This loop helps us repeat an action again and again until the game stops. For example, if we want a character to keep walking forward, we can use a forever loop and tell it to keep walking until the game stops.
By using these loops, we can make our games more interesting and exciting!
Jumping Chicken game setting
Let’s make a fun game called “Jumping Chicken” using Scratch!.
First, let’s go to scratch.mit.edu and login. Then, click on “create”.
You will see a cat on the screen. Click on the cat sprtie and then click on the bin to delete it.
Click on the “backdrops” option (mountain icon) and select the “blue sky” backdrop.
Click on the “sprite” option (cat icon) and add a new sprite called “chick”.
Click on the “sprite” option (cat icon) again and add a new sprite called “egg”.
On the left side of the screen, click on “variables” and create a new variable called “score”.
Setting initial values
Select the “chick” sprite and go to “events” select “when green flag cliked” then go to “motion” and Choose “go to XY” and set X as -180 and Y as -120. This will be the starting position for the chick.
Still on the “chick” sprite, go to “variables” and select “set score to zero”. This will set the score to zero when the player starts a new game.To make the chick jump and score points, go to “events” and select “when space key pressed”. When you press the spacebar, the code below will run.
Go to “sound” and select “start sound chirp” to make the chick chirp when it jumps.
Go to “motion” and select “change y by 10”. Then, go to “control” and select “repeat 10”. Snap these two blocks together and put them under “start sound”. This will make The chick jump up by moving 10 steps each time, and it does this 10 times in a row. We don’t make it move up 100 steps at once because it would be too fast to see the movement.
Go back to “motion” and select “change y by -10” to make the chick come back down. Then, go to “control” and select “repeat 10”. Snap these two blocks together and put them under the previous blocks.
To score points, go to “variables” and select “change score by 1” under the blocks that make the chick come back down.
Making the egg move
Click on the egg sprite you will see egg shadow in the coding area.
To make the egg move towards the chick, go to “events” and select “when green flag clicked”.This will make the following code run immediately when we start the game.
Go to “motion” and select “go to XY”. Set X as 240 and Y as -140 to make the egg start at the beginning point (on the right of the screen).
Go to “motion” again and select “glide 1 sec to XY”. Set time to 3 seconds and X as -240 and Y as -140. Snap these two blocks together and put them inside a “forever” block under “when green flag clicked”. This will make the egg move towards the chick and back to it’s starting point until we stop the game.
To check if the egg hits the chick and cracks, at the first time by go to “events” and select “when green flag clicked”. Then, go to “looks” and select “switch costume to egg-a”.
Go to “control” and select “wait until”. Then, go to “sensing” and select “touching chick”. Snap this block under “switch costume to egg-a”. This will check if the egg hits the chick.
Go back to “looks” and select “switch costume to egg-b”. This will make the egg looks like it has cracked when it hits the chick.
Finally, go to “control” and select “stop all”. This will make the game stop after the chick hits the egg.
Try your game by clicking on the green flag and hitting the spacebar to make the chick jump! Good luck!