Simple canvas 2d physics

We were out playing pool a couple of nights ago. Instead of betting money on the games we used code-hours. I'm not very good at pool so in the end i was lucky to only owe my friend one code-hour.
He wanted me to code a physics "demo" on a canvas element. Since i only had one hour to code we limited the "demo" to 2d and circles :) The implementation is quite ugly and the physics formulas are pretty much taken from an article at gamedev (which i can't find at the moment).


The result of my code-hour can be found at:


Anonymous said...

The collision detection/response is nice. The code could use a little cleaning, and there could be some sort of friction added, but it's nice for only an hour of code.

123 said...