Bouncing - Sprites

by virnuls
  scripts
  sprites
See inside
Instructions

If you click the flag, the beach ball will move in a random direction. It will then continue to move, bouncing off the edges of the screen and the purple spot. You can adjust the initial speed of the ball using the variable called speed, and the rate at which the ball slows down using the variable called restitution

The result isn't always perfect - can you improve it?

Notes and Credits

A demonstration of how to bounce one sprite off another. Bouncing can be tricky in Scratch - there is a tile to bounce off the edge, but not a bounce tile to bounce off anything else.

In this program, when a collision occurs, the direction of the ball is stored and then it turns to face the spot. The difference between the two angles is used as the angle of incidence, which can be used to calculate the new direction.

Click here to view a more detailed explanation: https://www.youtube.com/watch?v=34KXu7Up_4Q

Shared: 26 Jun 2013 Modified: 10 Nov 2014
Favorite this project 5
Love this project 7
Total views 1170
View the remix tree  5
  
More projects by virnuls