ScratchData LogoScratchData
Back to eRKSToCK's profile

Elastic balls (collision math by amcerbu)

EReRKSToCK•Created March 14, 2013
Elastic balls (collision math by amcerbu)
63
33
1535 views
View on Scratch

Instructions

Switch between showing the grid and turning it off. it runs faster with the variable set to 0

Description

The script for the math behind the collisions where from amcerbu. Things I've added: - run without screen refresh - fixed a bug from amcerbu's collision where two balls would stick to eachother, now the colliding ball backs off from the other so that they dont touch each other after the velocity has been calculated. This even works if the balls would be spawned at the same location, or if they would touch when they spawn. - The grid was an optimization thing I added. A ball only has to check for collision in its 2x2 square in the grid, which means two balls will only check for collision if their squares overlap. ***

Project Details

Project ID10078522
CreatedMarch 14, 2013
Last ModifiedJune 16, 2013
SharedMarch 15, 2013
Visibilityvisible
CommentsAllowed