top of page

Collision Detection

These past two weeks I have simplified the hierarchy of classes present at this stage, which will make development easier going forward. There is a Game class which handles the game logic, which may later be extended to allow multiple game modes, a Canvas class which renders the scene with each game tick, and various classes to represent the objects needed for the game such as balls and rails. This more closely follows MVC architecture compared to the previous soup.

I have also implemented rail collision as well as collision response to update the vectors of ball objects when collisions are detected, although ball-on-ball collision has not been completed yet, so in this regard I am just behind my ideal schedule. To counter this in some respect I have made some design decisions with respect to the user interface and how to complete the implementation for a working game/rules model, which I will work on in the coming weeks.

Additionally I have simulated the loss of momentum due to friction which causes the velocity of ball objects to decay both over time, and directly following collisions. Notably this required an optimisation where speed is zeroed as it tends to zero in order to prevent increasingly long floats being generated, which would harm performance. Pictured is a skeletal visual representation, modified here for demonstrative purposes, of a ball coming to rest after an initial force has been applied, starting from the mid-point of the table.

bottom of page