Click on the screen to place some nice balls. Press e to spawn in x amount of balls. Press s to set the balls size(in pixels). Modified to a linear algorithm for collision detection. Try turbowarp: https://turbowarp.org/760155655?fps=250&hqpen&limitless&turbo&offscreen Turbowarp will be able to support 10-20x more balls, smaller and smoother balls too. DO NOT LOOK AT THE CODE.
Updated with region based collision detection bringing time complexity from O(n^2) to O(n) with a large coefficient. 2/23/2024