How to use the Move Block to make a character move diagonally

Are your young coders ready to master a special kind of movement? Today, we are learning a clever trick in ScratchJr by using two separate Move blocks at the same time to make a character move diagonally! This is a simple but powerful technique for adding realistic motion to your projects.

Our project today will demonstrate this skill by having Kitten walk diagonally along a river. This teaches children the concept of multithreading or running multiple scripts simultaneously.

Setting the Scene for Diagonal Movement

To begin, we need a good setting for our diagonal path.

  1. Change the Background: Select the river background. [00:17]
  2. Position Kitten: Place Kitten at a starting point where they can move both to the right and down.

We must code two separate scripts for the Kitten icon, and both must begin with the Green Flag.

Coding for Diagonal Movement: Two Simultaneous Scripts

To move diagonally, a character must move along the horizontal axis (left/right) AND the vertical axis (up/down) at the exact same moment. We achieve this by running two independent programmes simultaneously.

H2. Script 1: Horizontal Movement (Right)

This programme controls the character’s movement across the screen.

  1. Start Block: Begin the first script with the Green Flag trigger block (yellow category). [00:39]
  2. Movement Block: Go to the blue Motion category and add the Move Right block. [00:47]
    • Set Distance: Determine how far right you want Kitten to move (e.g., set to 9 steps). [01:35]
  3. End: Finish the script with the red End block.

H2. Script 2: Vertical Movement (Down)

This programme controls the character’s movement up or down the screen.

  1. Second Start Block: Begin a second, separate script with a Green Flag trigger block (yellow category). [00:54]
  2. Movement Block: Go to the blue Motion category and add the Move Down block. [01:05]
    • Set Distance: Determine how far down you want Kitten to move (e.g., set to 7 steps). [01:42]
  3. End: Finish the script with the red End block.

Achieving the Perfect Diagonal

When you press the Green Flag, both scripts start running instantly. The computer makes Kitten move both right and down simultaneously, resulting in a smooth diagonal line of movement. [01:19]

  • Customising the Angle: The angle of the diagonal line is determined by the numbers you set. If you set the Move Right block and the Move Down block to the same number (e.g., both set to 5), Kitten will move in a perfect 45-degree diagonal line. [02:23]
  • Changing Direction: To move up and to the left, you would simply use the Move Up and Move Left blocks instead.

Mastering this technique with two simultaneous ScratchJr blocks is a major step in coding tutorials and allows for much more flexible and creative character animations. For structured lesson plans, explore our collection of ready-made lessons. Happy coding!