IOCT Masters in Creative Technogies
Major Project
An augmented reality game based on "Breakout"

Friday 4 July 2008

Brick collision from below to right

The code for this is similar to collision detection when the ball is travelling to the left, using i+1 instead of i-1, as used when the ball is travelling to the left.

x1 = (bricks1[i+1].posx – bricks1[i+1].halfwidth) – prevballx – gameball.radius + 4;






Again, check that the collision occurs between the top and bottom of the brick, add one to the hit count each time a brick is hit, add ten to the score when a brick is deleted, reverse the ball direction, calculate the final ball position and check if the level has been completed.