Skip to main content

Programs and motion

Activity: Add a new program

Let's add that when you press the "a" key, the sprite rotates 90 degrees:

  1. We will have to use an Events block, specifically the "when space key pressed" block. I put space in italics because we can change it. By clicking on "space", we can change it to "a".
  2. The Movement block "move 10 steps" is also needed. By clicking on the 10, we could set it to 100 to advance further.

imagen.png

Notice that there are 2 programs in the central area. Each sprite can have several programs, which work in parallel.

IMPORTANT: The programs are identified by starting with an "Events" block whose upper part is oval.

Practical case I

The sprite moves in the direction it is pointing. There is a block that makes the sprite point to another address:

imagen.png

Make the sprite move according to the keyboard arrows.

Solution:

imagen.png




Practical case II

The position of a sprite is controlled with X and Y coordinates. The position of these coordinates on the screen is as follows:

This image is a backdrop that is already created in Scratch (XY-grid), and that you can add to your project.

Add this program

imagen.png

What does this program do?

Solution


This program moves the object to the lower right area of the screen when the b key is pressed.