For this project we are going to continue working with our Scratch Coins file. Ww will learn more advanced Scratch codes that we will use to make our game more challenging and more fun.
Today we will learn how to use the Sensing Blocks in Scratch to make Gravity.
First Steps - Getting your File Ready
First we want to take away some code from our file. When we have the Sprite jump, we already tell it to go up and then down again. We should get rid of the Wait and Change Y by -10 blocks so that our Sprite only goes up.
We also want to add a Sprite that will be the ground, so the Sprite knows when to stop falling. Just using a green rectangle and putting it at the bottom of the screen is fine.
Using Sensing Blocks for Rules
Every game has rules. It is the different rules in different games that make them challenging, and that is what makes them fun. If a game is too easy to win, no one wants to play it for very long. Today we are going to add a rule to our game. Our game will have gravity, which means that our Sprite will fall back to the ground whenever it is up in the air.
To make Gravity we will use an IF STATEMENT with code from the SENSING and OPERATORS section. We will learn more about OPERATORS later, just know that they are used with IF STATEMENTS. To make Gravity:
- Use a FOREVER IF STATEMENT
- Use a NOT block from the Operator Menu.
- Use a TOUCHING COLOR from the Sensing Menu.
- Use a Change Y block.
How can we put these together to make our Sprite move lower toward the ground whenever it is not already on the ground?
Combine the Blocks we talked about to make Gravity for your game.
Add more coins and put them in places where it might be more challenging to get to them.
Back to School Portal