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 the 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 another “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 sprites 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 dropdown 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 pressed” 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!

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.

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
Say Something
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.