This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective. |
Point Away From Edge | |
point away from edge::motion | |
Category | Motion |
Type | Stack |
Introduced in | 02Dec05 (0.x) |
Removed in | 27Jul06 (0.x) |
The point away from edge block was a stack block and a motion block. The block pointed the sprite away from the closest edge. In the Java Player, the block works as a normal if on edge, bounce block instead. It was removed in Scratch 27Jul06 for an unknown reason, and it was made an obsolete block.
This block was known as "turn away from edge" before being renamed in Scratch 16Dec05.
Example uses
Some example use cases for this block include:
- Recreating the if on edge, bounce block (as this block was not available in older versions of Scratch)
if <<not <(abs (x position):: operators) < (240)>> or <not <(abs (y position):: operators) < (180)>>>:: control point away from edge:: motion end
- Creating patterns with the pen
when gf clicked:: control point in direction (140 v) clear pen down forever { move (pick random (1) to (100)) steps point away from edge:: motion }:: control cap
Workaround
- Main article: List of Block Workarounds
This block can be replicated with the following script:
if <not <(y position) < (0)>> then if <((x position) - (240)) > ((y position) - (180))> then point in direction ((0) - ([abs v] of (direction))) // top right end if <((x position) - (240)) < ((y position) - (180))> then if <((-240) - (x position)) > ((y position) - (180))> then point in direction ([abs v] of (direction)) // top middle end if <((-240) - (x position)) < ((y position) - (180))> then if <(90) > ([abs v] of (direction))> then point in direction ((180) - (direction)) // top left end end end end if <not <(y position) > (0)>> then if <((x position) - (240)) > ((-180) - (y position))> then point in direction ((0) - ([abs v] of (direction))) // bottom right end if <((x position) - (240)) < ((-180) - (y position))> then if <((-240) - (x position)) > ((-180) - (y position))> then point in direction ([abs v] of (direction)) // bottom middle end if <((-240) - (x position)) < ((-180) - (y position))> then if <(90) < ([abs v] of (direction))> then point in direction ((180) - (direction)) // bottom left end end end end
This script can be condensed down at the loss of some parity:
if <(y position) > (0)> then if <((x position) - (240)) > ((y position) - (180))> then point in direction ((0) - ([abs v] of (direction))) // top right else if <((-240) - (x position)) > ((y position) - (180))> then point in direction ([abs v] of (direction)) // top left else if <(90) > ([abs v] of (direction))> then point in direction ((180) - (direction)) // top middle end end end else if <((x position) - (240)) > ((-180) - (y position))> then point in direction ((0) - ([abs v] of (direction))) // bottom right else if <((-240) - (x position)) > ((-180) - (y position))> then point in direction ([abs v] of (direction)) // bottom left else if <(90) < ([abs v] of (direction))> then point in direction ((180) - (direction)) // bottom middle end end end end