Ball.js - v2.0
v2.0 - Work in progress, more features to come for this version !
Ball.js is a Javascript class that handles physics interactions between balls (i.e. collisions) on a flat area as well as rendering.
You can render in canvas mode as well as in html mode.
You have a bunch of display effects such as glowing, blinking, exploding (changing the radius, color, alpha) ...
I made an HTML5/Javascript game based on this class. You can see it in action on http://bombs.topheman.com
There you can try the demos :
This class could be used in all kinds of animations and games such as pool billard or air hockey ...
V2 - changelog :
- added method .toRadius()
- changed options.explodingRadius to options.explodingRatio
- added .checkEdgeCollision() method
- added .resolveEdgeCollision() method - need HELP for this one please ! angle resolution problem as you can see on this example : V2 - Edge bounce (canvas only) ...
Help needed
Comme vous le verrez dans l'exemple suivant, j'ai deux principaux problèmes que je n'arrive pas à résoudre sur Ball.js :
- méthode .resolveEdgeCollision() : les angles de rebonds ne sont pas cohérents
- méthode .checkEdgeCollision() : si la vélocité de la ball (la longueur qu'elle parcourt à chaque frame) est supérieure à son diamètre, potentiellement, elle passera à travers un segment et ne déclenchera pas de collision
Cette version est la 2.0, elle est sur une branch du github du projet Ball.js
As you will see on the demo, I have two major problems that I'm having a really hard time to solve on Ball.js :
- method .resolveEdgeCollision() : bounce angle is inconsistent
- method .checkEdgeCollision() : if the ball's velocity (the length that it runs each frame) is higher than its diameter, eventually, it will pass through an edge, without triggering any collision
This version is 2.0, it's on a branch of the github project Ball.js
Demo (V2 - Edge bounce)
copyright © 2012 Christophe Rosset (Topheman), released under Creative Commons 