Instructions on how to create a Jumping game in Scratch
Are you looking for a way to create an obstacle course jumping game in Scratch? This article will guide you step-by-step to create a platform jumping game.
Are you looking for a way to create a jumping obstacle course game in Scratch ? This article will guide you step-by-step to create a game where you jump across platforms and overcome obstacles to achieve accomplishments in Scratch.
What is a jumping game?
Have you ever played the Dinosaur Jumping game whenever you experienced internet connection problems or couldn't access a website? It's a very popular jumping game developed by Google in 2014. Now, it's a standard game available in the Google Chrome browser whenever there are internet outages.
Essentially, a jumping game is a type of video game where you control a character by performing jumping actions. The main objective is usually to navigate through a series of platforms, obstacles, and challenges by timing your jumps and avoiding hazards.
How to create an obstacle course jumping game using Scratch
Creating a platformer game in Scratch is a fun and engaging way to learn programming. Jumping is a key mechanism in this genre, allowing the character to move from one platform to another.
Here are some important terms to know before you begin, followed by a step-by-step guide to making your Scratch sprites jump.
- Sprite: A character or object in Scratch that can be programmed to move and interact.
- Outfit: Different shapes of the same sprite (e.g., oriented to the left versus oriented to the right).
- Y-position: The vertical position of a sprite (the higher the y-position = the higher it is on the screen).
- X position : The horizontal position of a sprite (the higher x = the further to the right).
- Color detection: A Scratch feature that detects when a sprite touches a specific color, used here to detect contact with the ground/platform.
Here are the steps to create an obstacle course jumping game using Scratch:
Step 1: Set up the game environment
Create the ground and base.
- Draw an image of the ground for your character to stand on.
- Add images of platforms for your character to jump onto.
Tip: Make sure the color of the top surface of the pedestals exactly matches the color of the ground. If you look at the example below, both the ground and the top surface of the pedestals are light purple.
Position and resize images
- Arrange the ground, platforms, and character images in the game preview window to build your basic game layout.
Step 2: Prepare character images
Add outfits to move in that direction.
The character's image needs to have at least two outfits: Right and Left. This will allow the character to rotate when the arrow keys are pressed.
- Draw the character facing to the right side of the screen.
- Right-click on the outfit and select Duplicate .
- Select all the characters, then click Flip Horizontal to create a version facing left.
Step 3: Program character movement
Move to the right and left.
Choose a character image and add the following code:
1. Select the player character image and add the code "when right arrow key pressed" to the code area.
2. Attach the code blocks "switch costume to Right" and "change x" with the value "20" .
3. Right-click and select "Duplicate" the code block, then change the key to the left arrow.
4. Change the outfit to "Left" and the value of "x" to "-20" .
| Direction | Key | Skin | Change x |
| Right | Right arrow | Right | +20 |
| Left | Left arrow | Left | -20 |
Step 4: Program the jumping mechanism
Jump up
In Scratch, jumping is achieved by changing the character's y-position. First, add the command "when up arrow key pressed" to the code area. Then, attach the "repeat" block set to "15" , and place the command "change y" to "10" inside it.
Falling
When you jump in real life, gravity naturally pulls you back to the ground. In Scratch, you need to program this manually.
- Attach the "repeat until <>" block below the previous repeat block.
- Click on the "color" variable and then select the dropper tool from the "color" menu .
- Hover your mouse over the "Ground" color and then click to select it.
- Inside the "repeat until" block , add the command "change y" with "-10" .
TIP: If there's a platform directly above your character, you might get stuck on the first jump. This happens because the top of your character is technically touching the background, and so it thinks there's no need to fall! Here's how to fix it:
In the "repeat 15" block , place the "if <> then" block below the "change y" block. Then, add color to the "if" brackets and choose the background color of the base, and then inside the "if" block , add "change y" equal to "-10" .
That's it! The Jumping game is now complete on Scratch.
- How to create a virtual pet game in Scratch
- How to make a piano game using Scratch
- Scratch: A guide to creating an opening for a project
- How to Create a Racing Game in Scratch
- How to create a maze game in Scratch
- How to Create a Two‐Player Boat Racing Game in Scratch
- How to make snow fall in Scratch
- Programming the game Cat and Mouse with Scratch