Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Bug Fix: Land on Your Feet...or Not

Transcript

In this video, you'll fix a bug to make the sprite land on its feet.

Currently, the sprite stays on the platform, even if its feet are not touching it.

This is because of how it's programmed.

The if statement that moves the sprite down reads, "If touching sprite."

It doesn't make sense for the sprite to stay on the platform if another body part, like it's head is touching it.

In this add-on, you'll change the code so the sprite stays on the platform only when its feet are touching it.

The best way to check if a part of one sprite is touching another sprite is to use a color.

To do this, give the sprite's feet a unique color.

This example changes the color to green, but you can make the bottom of the sprite any color you want.

Depending on what your sprite looks like, and how it's shaped, you may need to get creative with the pen or line tool to give the bottom of the sprite a unique color.

Now, instead of saying, if not touching the color black, move down, say, if the color green, which is the color of the sprite's shoes, is not touching the color black, then move down.

Change the color swatch in the touching color block.

Test your code.

Awesome, if the sprite is touching the platform with anything but its shoes, it keeps falling.

But, if the green shoes are touching the platform, the sprite doesn't fall.

Now it's your turn.

Change the color of the bottom of the sprite.

Program in the sprite to stop falling only if its feet are touching the black platform.

Choose an Add-On
Time to Celebrate!
Create a wild winning celebration using some of these ideas.
Moving Platforms
Make your game more challenging by creating moving platforms.
Shrinking Platforms
Create a shrinking platform to increase your game's difficulty.
Splash! You Lose
Create a way for the player to lose in your game.
Add Some Tunes
Add some background music to your game.
Bug Fix: Land on Your Feet...or Not
Fix the bug that allows things other than a sprite's feet to keep it on a platform.
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!