I want to create bouncing ball program that's very easy on Flash, Python or Delphi yet very tricky on html5. The program consist of n ball with random velocity (each) moving in a 2d box (oh yeah, square then :) )
I am playing with array in html5 script which is helpful on this program. I don't declare the array using
aBola = new array()
that come as standart on many language, but prefer
aBola = []
instead, just like list on python. In this program, array's just like container for ball.
In html5, moving an object is a bit tricky and, for some Pascal programmer like me, bringing an old memory of draw-clear-draw-clear... cycle; draw a ball, delete it, draw the same ball but slightly right, delet it, ... and so on. All that kind of tedious job, but it worth for the sake of fast execution and no-need-slow-loading-flash-player thing.
I used on 1D collission problem where, in case of elastic collision, the ball is changing velocity each other. In 2D/3D case however, the collision is not always head-on collision (which is basically 1 dimension collision).
Head-on
The system above's easy too solve, as simple as interchanging velocity (in elastic case).