Switch between showing the grid and turning it off. it runs faster with the variable set to 0
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. ***