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 Make Them Jump

Transcript

In this add-on, program your characters to move when you press the arrow keys so that they can avoid the glitch.

First, move the sprite using blocks from the Motion menu.

To make the sprite move to the right, click on the Change x By block.

Great, the sprite moves to the right.

Drag this block out.

To make the sprite move to the left, drag out another Change x By block.

Change the value to a negative number.

Click the block to test.

Nice, the sprite moves in the opposite direction.

Next, program your sprite to jump.

A jumping motion will require the sprite to move up then down.

Drag out a Change y By block.

Click this block a few times.

The sprite moves up a little bit each time.

Drag down the sprite.

To move the sprite down after it jumps up, drag out a Change y By block.

Change the value to a negative number.

When the first Change y By block is clicked, the sprite jumps up.

When the second Change y By block is clicked, the sprite comes back down.

Next, tell the code when to run.

The code should run if a key is pressed.

Click on the Control menu and place an If block around each movement block.

Snap them together.

Drag out Key Pressed blocks from the Sensing menu and place them in the If blocks.

Select a different arrow key from each drop down menu.

In this example, this block stack moves the sprite right so right arrow is selected.

Select left arrow and up arrow for the other key press blocks.

Try it out.

Oh no!

The code doesn't work.

This is because the program is not constantly checking for key presses.

To fix this, drag out a Forever block from the Control menu and place it around your block stacks.

This makes the code run over and over again so the sprite moves every time an arrow key is pressed.

But wait, the sprite doesn't jump when the up arrow key is pressed.

The code is running so fast, it's difficult to see the sprite jumping.

To fix this, add a Wait block from the Control menu.

Try it again.

Great, the sprite jumps up and down.

Tinker with the values in the Change x By and Change y By blocks to change the distance the sprite moves and jumps.

To better time the jump, change the value in the Wait block.

This example uses 0.2 seconds.

Finally, add a When Flag Clicked block to the top of the block stack so that the sprite can move in any direction when the program runs.

Click the green flag and press the arrow keys to tell your story.

(upbeat music)

Now it's your turn.

Drag out Change x By blocks to move left and right.

Drag out Change y By blocks to move up and down.

Add If and Key Pressed blocks around each block stack.

Add a Forever block to constantly check for key presses.

Add a Wait block to time the jump.

And finally, add a When Flag Clicked block to start the program.

Choose an Add-On
Place to Place
Use move blocks to add drama to the story
Hear It Happen
Create custom sounds to play randomly with the glitch
Even Glitchier
Make the glitch effect your backdrop
Make Them Jump
Program your characters to move with arrow keys
GIF for your Glitch
Upload a GIF and animate it to change your story
Costume Change
Use blocks to change your Sprite's appearance
arrow_backward Back
Next arrow_forward
Instructions
Draw your story toward a conclusion using dialogue, scene changes, or new characters.
Attributions
  • "Gumball | The Signal | Cartoon Network" by The Amazing World of Gumball (https://www.youtube.com/watch?v=CftA5oEXetE&t=0s&index=92&list=PL77ED97B132C66551) -- Licensed by Standard Youtube License (https://www.youtube.com/static?template=terms)