If on Edge, Bounce (block)
|If on Edge, Bounce|
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 is coming. It uses a line perpendicular to the edge to determine the reflection angle.
- Preventing a sprite from partially leaving the screen (often, this is followed by the Point in Direction block to stop reflection)
- Games such as "Pong"
- Allowing sprites to bounce off the screen:
when gf clicked forever if on edge, bounce move (5) steps
- It also works for games such as fish.
forever turn cw (pick random (-10) to (10)) degrees move (3) steps if on edge, bounce wait (0.01) secs
|This article or section needs additional citations for verification. Its information may not be accurate. Editors can help by adding references.|
Some users in the suggestions forum have requested for a block to be implemented simply called "bounce", which would allow for sprites to bounce when they collided with other sprites or with colors.
However, they are often rejected because it is impossible to bounce off a general shape without calculus.