(Redirected from Y Position (value))

"X" redirects here. For the information about the social media site, see Scratch on Social Media#Twitter.
An XY grid.

Scratch determines where to display sprites through the coordinate system, or a mathematical grid of infinite values. It uses the Cartesian coordinate system in which on a two-dimensional plane, a point has two values to locate or reference its exact position.

Positions

Scratch's coordinate system uses 2 coordinates: X position and Y position, to determine the location of a sprite on the stage. The X position value determines the horizontal location of the sprite and the Y position value determines the vertical location or height. The screen is a 480x360 rectangle with the origin in the center, such that the X position can range from 240 to -240, where 240 is the rightmost a sprite can be and -240 is the leftmost, and the Y position can range from 180 to -180, where 180 is the highest it can be and -180 is the lowest it can be. Large sprites can be moved past the edge of the stage, but at least 15 pixels of the sprite always remain visible.[1]

Coordinates are, by convention, written as a pair (X, Y): for example, the center of the screen is (0, 0).

In this system, (0, 0) is considered the center of the screen; unlike many popular coordinate systems such as Quartz 2D and the HTML5 canvas API, which use (0, 0) as the top-left or bottom-left corner. This point (0, 0) is called the Origin.

This is also called a Cartesian coordinate system, and is an essential part of elementary algebra. (Specifically, most equations and expressions in algebra can be graphed on the Cartesian plane so to produce various shapes. For example, a line defined as x = y will produce a diagonal line.)

Blocks related to the X position

The X position of a sprite can be determined, set, and changed by the following blocks:

Blocks related to the Y position

The Y position of a sprite can be determined, set, and changed by the following blocks:

Directions

Main article: Direction (value)

Direction is determined by a rotational number system. The direction 0 is straight up. Every 90 units are equivalent to a quarter turn, where +90 is 90 degrees clockwise and -90 is 90 degrees counter-clockwise. The diagram below shows how this works.

Direction Diagram.png

The direction never exceeds 180 or goes below -180; it is always (internally) kept within these limits. A similar way to clamp the direction would be:

set [clamped direction v] to ((((old direction) + (179)) mod (360)) - (179))

However, it is usually more helpful to set the direction from 0° to 360°, purely for convenience.

Any direction is equal to 360° + the direction: 90° = 90° + 360° = 450°.

These are similar to polar coordinates, except rotated 90° counter-clockwise. A polar coordinate consists of an angle and the distance away from the origin.

References

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.