I made a simple ball bouncing program with VC++.
the goal of this program is that ball must bounce in the rhombus. it cannot go out of rhombus.
It seems that it runs successfully, but in the left and right corner, it stuck.
How to resolve this problem? I think the condition of equlation is duplicated when the ball is going to left and right corner...
Can you suggest other algorithm for solve this problem?
i tried to make this problem like
while(!isInside(getNextPos(circle))) { updateDirectionVector(circle); }
but I cannot do like this because a random value has changed in everytime. (Used Timer to repeat)
This is algorithm of this program which is worked except at the corner.
up:
while(1) goDownSideCircle;
if(StuckOnDownSide) goto down;
down:
while(1) goUpSideCircle;
if(StuckOnUpSide) goto up;