Motion

Motion
Extension Description
Motion blocks are used to control a sprite’s movement.

Introduction

Motion is one of the ten categories of default Scratch blocks. They are color-coded medium-blue and are used to control a sprite’s movement.

Note: The Stage does not have any motion blocks and cannot use them.

Using Motion Functions in Python

The motion functions can be used in Python with the sprite object defined:

sprite = Sprite('Ball')
Read More

PictoBlox Blocks

The block moves its sprite forward the specified amount of steps in the direction it is facing. A step is equal to one-pixel length. The block actually uses Trigonometry to move in the proper direction, as that is how a computer handles it.
The blocks turn their sprite the specified amount of degrees clockwise. This changes the direction the sprite is facing.
The blocks turn their sprite the specified amount of degrees counter-clockwise. This changes the direction the sprite is facing.
The block points its sprite in the specified direction; this rotates the sprite.
The block points its sprite towards the mouse-pointer or another sprite depending on its costume center; this changes the sprite’s direction and rotates the sprite.
The block sets its sprite’s X and Y position to the specified amounts. This block has no animation in its movement — it is the simplest way to move a sprite around the screen without displaying any animation (i.e. gliding). Therefore, this block is used whenever a sprite needs to jump to another spot.
The block sets its sprite’s X and Y position to that of the mouse-pointer or another sprite — in other words, it moves the sprite to a random position, the mouse-pointer, or another sprite.
The block glides sprite to the specified X and Y position in the specified duration. This block has animation in its movement.
The block moves its sprite steadily to the specified X and Y position in the specified amount of seconds – this is like pointing the sprite in a direction and repeatedly using Move () Steps, but with more precision. A disadvantage of the glide block, however, is that it pauses the script while the sprite is moving, preventing the script from doing other things while the sprite is gliding.
The block moves its sprite costume center’s X position by the specified amount.
The block changes the selected sprite’s X position to a specified value.
The block moves its sprite’s Y position by the specified amount.
The block sets its sprite’s Y (up and down) position to the specified amount.
The block checks to see if its sprite is touching the edge of the screen with the move steps block — and if it is, the sprite will point in a direction that mirrors the direction from which it is coming. It uses a line perpendicular to the edge to determine the reflection angle.
The block changes the Rotation Style of the sprite in-project. Regardless of the style, the variable direction will still change.
The block holds its sprite’s X position. This block can be displayed as a Stage monitor.
The block holds its sprite’s Y position. This block can be displayed as a Stage monitor.
The block holds its sprite’s direction, measured in degrees.
All articles loaded
No more articles to load

Block Coding Examples

All articles loaded
No more articles to load

Python Functions

The function moves its sprite forward the specified amount of steps in the direction it is facing. A step is equal to one-pixel length.
Syntax: move(steps = 10)
The function turns the sprite by the specified amount of degrees clockwise. This changes the direction the sprite is facing.
Syntax: right(angle = 15)
The function turns the sprite by the specified amount of degrees counter-clockwise. This changes the direction the sprite is facing.
Syntax: left(angle = 15)
The function sets its sprite’s X and Y position to that of the mouse-pointer or another sprite — in other words, it moves the sprite to a random position, the mouse-pointer, or another sprite.
Syntax: goto(moveto = “_random_”)
The function sets its sprite’s X and Y position to the specified value. This block has no animation in its movement — it is the simplest way to move a sprite around the screen without displaying any animation (i.e. gliding).
Syntax: gotoxy(x = 100, y = 100)
The function points its sprite in the specified direction; this rotates the sprite.
Syntax: setdirection(angle = 15)
The block points its sprite towards the mouse-pointer. This changes the sprite’s direction and rotates the sprite.
Syntax: pointto()
The function moves its sprite costume center’s X position by the specified amount.
Syntax: changex(delta_x = 10)
The function changes the selected sprite’s X position to a specified value.
Syntax: setx(x = -240)
The function moves its sprite’s Y position by the specified amount.
Syntax: changey(delta_y = 10)
The function sets its sprite’s Y (up and down) position to the specified amount.
Syntax: sety(y = 27)
The function checks to see if its sprite is touching the edge of the screen with the move steps block — and if it is, the sprite will point in a direction that mirrors the direction from which it is coming. It uses a line perpendicular to the edge to determine the reflection angle.
Syntax: bounceonedge()
The function changes the Rotation Style of the sprite in-project. Regardless of the style, the variable direction will still change.
Syntax: setrotationstyle(rotation_style = “left-right”)
The function returns the sprite’s X position.
Syntax: x()
The function returns the sprite’s Y position.
Syntax: y()
The function returns the sprite’s direction in angle.
Syntax: direction()
All articles loaded
No more articles to load

Python Coding Examples

All articles loaded
No more articles to load
Table of Contents