Menu
IDS - Collision Bounce
Bounce
In the example on the right, we us several IF statements to ask if the player goes off the side. If it does, then the location of the player is changed to the opposite side.
However, the goal object is expected to bounce off of the sides. In that case, when it reaches one side or the other, it will reverse the vector by multiplying by -1. Notice that the vector (gVectorX) is reversed exactly the same regardless of which side it hits.. After collision checks are done, and we have responded to collision, then we plot our objects. |