If on Edge, Bounce
if on edge, bounce
Category Motion
Type Stack

The If on Edge, Bounce block is a Motion Block and a Stack Block. 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 was coming. It uses a line perpendicular to the edge to determine the reflection angle.

The block can also be combined with the option on a sprite to control their movement to left and right only as this prevents the sprite from turning upside down.

Example Uses

  • Preventing a sprite from partially leaving the screen (often, this is followed by the Point in Direction block to stop reflection)
  • Reflection
  • Games such as "Pong"
  • Allowing sprites to bounce off the screen:
when gf clicked
if on edge, bounce
move (10) steps
  • It also works for games such as fish.
when gf clicked
turn cw (pick random (-10) to (10)) degrees
move (3) steps
if on edge, bounce
wait (0.01) secs

Bounce Block

Some users in the suggestions forum have requested a generalized "bounce" block, which would allow sprites to bounce when they collide with other sprites or with colors.[1][2][3]

However, they are often rejected, because implementing such a block for general shapes requires calculus.[4][5]

See Also


  1. http://scratch.mit.edu/discuss/topic/38010/
  2. http://scratch.mit.edu/discuss/topic/35247/
  3. http://scratch.mit.edu/discuss/topic/31897/
  4. https://scratch.mit.edu/discuss/topic/38010/?page=1#post-316964
  5. https://scratch.mit.edu/discuss/topic/31897/?page=1#post-556026