Motion Blocks
Steering characters through steps and degrees
Definition
Motion blocks are code instructions that change a sprite's position (steps, slide to coordinates) or orientation (turn degrees). Key concepts include Hat Block, Sensing Block.
Think of Motion Blocks as:
Just as an actor changes costume or walks across the theater grid on cue, Motion Blocks dictates sprite behavior.
Real-Life Example
Just as you coordinate actions in real life, Motion Blocks works by structuring logic commands in sequence:
- 1 Register the trigger event block.
- 2 Run calculations or movements within a continuous control block.
- 3 Update values or graphics on the stage viewport.
Key Highlights:
- Trigger event
- Logic evaluation
- Visual update
Interactive Diagram
Launch the interactive diagram to see this in action.
Open Interactive DiagramThe interactive diagram for this chapter demonstrates Motion Blocks. It shows motion blocks (move, turn, go to, glide) being applied to a sprite, showing movement on the stage.
What to explore:
- click different motion blocks; watch the sprite move according to each block; combine blocks to create a movement sequence
- motion blocks control a sprite position and movement on the stage using coordinates, direction, and speed
Introduction
Movement brings your Scratch projects to life. Without motion, your characters would be frozen in place, unable to explore, chase, dodge, or dance. Motion Blocks are the tools that let you control where sprites are and how they move around the stage. They are among the most commonly used blocks in Scratch programming.
The Motion category contains about 18 blocks that control sprite positioning, movement, rotation, and direction. Some blocks set absolute positions (go to specific coordinates), others change positions relative to the current location (move 10 steps), and still others control rotation and direction. Many Motion Blocks use the coordinate system (x and y values) that defines the stage.
In this chapter, you will learn how to use each type of motion block, understand the coordinate system deeply, and combine Motion Blocks to create smooth, interesting movement patterns. By the end, you will be able to make sprites walk, glide, spin, and bounce across the stage.
How It Works
The most fundamental motion block is 'move (10) steps', which moves a sprite 10 pixels in its current direction. The number of steps can be changed to any positive or negative value. Positive numbers move forward, negative numbers move backward. The direction is measured in degrees, with 0 pointing up, 90 pointing right (the default), 180 pointing down, and -90 (or 270) pointing left.
The 'go to x: () y: ()' block instantly moves a sprite to a specific position on the stage. The 'glide (1) secs to x: () y: ()' block moves the sprite smoothly over a specified time period. Gliding is useful for creating smooth animations like a ball rolling or a character walking. The 'set x to ()' and 'set y to ()' blocks change only the x or y coordinate independently.
Household Object Analogy
Think of Motion Blocks like giving directions to a friend. 'Move 10 steps' is like saying 'walk forward 10 paces.' 'Turn 15 degrees' is like saying 'turn slightly to the right.' 'Go to x: 0 y: 0' is like saying 'meet me at the town center.' 'Glide to x: 100 y: 50' is like saying 'walk to the coffee shop on the corner, taking your time to get there.'
Deeper Dive
The 'point in direction ()' block rotates the sprite to face a specific angle. Scratch uses a 0-to-360 degree system where 0 is up, 90 is right, 180 is down, and 270 is left. The 'point towards [sprite]' block automatically calculates the direction needed to face another sprite. This is extremely useful for enemy AI that follows the player or a turret that aims at a target.
The 'change x by ()' and 'change y by ()' blocks are essential for smooth, continuous movement. In a typical game loop, a script repeatedly adds a small amount to x or y to create movement. For example, in a 'forever' loop: 'change x by (5)' makes a sprite move right continuously. Negative values move left or down. This pattern is the foundation of nearly all game movement in Scratch.
The 'if on edge, bounce' block is a simple but powerful tool. When a sprite reaches the edge of the stage, this block reverses its direction, creating a bouncing effect. It works by detecting when the sprite's center reaches the edge and then reflecting the direction angle. This is how classic games like Breakout and Pong create bouncing ball behavior.
Key Insight
The 'move (10) steps' block actually moves the sprite in its current direction, not necessarily to the right. If the sprite is pointing up (0 degrees), 'move 10 steps' moves it upward. If pointing left (180 degrees), it moves left. This is a common source of confusion for beginners who expect 'move' to always go right.
Advanced
Scratch Motion Blocks can use negative values to reverse direction. 'Move (-10) steps' moves backward. 'Turn clockwise (-15) degrees' turns counterclockwise. 'Change x by (-5)' moves left. This is useful for creating back-and-forth motion patterns and for enemy behaviors that reverse direction when reaching a boundary.
The 'set rotation style' block changes how a sprite visually rotates. The default 'all around' style rotates the costume to any angle. 'Left-right' style flips the costume horizontally when the sprite changes direction — useful for side-scrolling games where a character should face left or right but not rotate fully. 'Don't rotate' keeps the costume at its original angle regardless of direction.
Motion Blocks can use mathematical expressions in their input fields. For example, 'move ((item 1 of [list]) * (speed)) steps' or 'go to x: (mouse x) y: (mouse y)'. This allows dynamic movement that responds to variables, sensor input, or calculated values, enabling sophisticated behaviors like smooth acceleration, deceleration, and trajectory following.
Vocabulary Table
| Term | Definition |
|---|---|
| Motion Blocks | The primary technological concept explaining how components interact within the context of Scratch Programming. |
| Coordinate Grid | The X and Y plane representing the Stage layout coordinates. |
| Hat Block | A block with a rounded top that registers events to launch scripts. |
| Sensing Block | A block that checks for collisions, touch parameters, or mouse pointer coordinates. |
Fun Facts
The 'move (10) steps' block actually moves the sprite based on a mathematical calculation using sine and cosine of the direction angle. The formula is: new x = old x + steps × sin(direction), new y = old y + steps × cos(direction).
The Scratch stage coordinate system places (0,0) at the center, which is different from many programming languages where (0,0) is at the top-left corner.
The 'glide' block was added in Scratch 1.3 and immediately became one of the most popular blocks for creating smooth animations.
Scratch sprites can rotate through 360 degrees, but the direction value ranges from -179 to 180. Values above 180 wrap around (e.g., 270 degrees becomes -90).
The 'set rotation style' block was added in Scratch 2.0. Before that, all sprites used the 'all around' rotation style by default.
Common Misconceptions
Misconception: The 'move (10) steps' block always moves the sprite to the right.
Truth: Move moves the sprite in its current direction, which defaults to 90 degrees (right). If the sprite's direction has been changed, 'move' will go in that new direction.
Misconception: 'Glide' and 'go to' do the same thing.
Truth: 'Go to' moves instantly, while 'glide' moves smoothly over a specified time. Use 'go to' for instant changes and 'glide' for animated movement.
Misconception: Changing x and y independently is the same as using 'go to'.
Truth: Changing x and y separately in two blocks creates a diagonal movement where the sprite moves first horizontally then vertically, not a straight diagonal. 'Go to' moves in a straight line.
Misconception: Motion Blocks only work for sprites, not the stage.
Truth: Correct — the stage cannot move. Motion Blocks are not available when programming the stage. Only sprites have position and direction properties.
Knowledge Check
1. What is the main role of Motion Blocks?
Answer: To orchestrate behaviors and controls visually
2. Which block shape starts a script stack in Scratch?
Answer: Hat block (curved top)
3. What is the maximum X coordinate limit on the stage?
Answer: 240
