-->
0 Members and 1 Guest are viewing this topic.
The ball falls from the cieling, due to gravity. the goal is to get the ball to the floor, without hitting the walls. There will be lines in the way of the ball, which the ball bounces off of. The only thing you can control is the rotation of the lines, as shown in the pictures below.The original level:Now, after you press the -> arrow on the keyboard:all of the lines have been rotated counterclockwise around the center point.
Well, actually collision testing is done by comparing the three points (first line point, second line point, and ball location) and testing if they are collinear, not by pxl-checking. but the 3-4 ticks before refresh is a good idea!
A surprisingly accurate approximation for arctangent is:Code: [Select]atan(x) ≈ (π/2)*x/(abs(x)+1)Which, when converted from radians, can be implemented in fixed point notation as x*64//(abs(x)+256) however this has overflow problems in the numerator. The best way to fix this issue is to split the equation into 2, one for large numbers, and one for small:Code: [Select]:Lbl atan:If abs(r1)+256→r2>768: Return 64-(16384//r2):End:Return r1*64//r2
atan(x) ≈ (π/2)*x/(abs(x)+1)
:Lbl atan:If abs(r1)+256→r2>768: Return 64-(16384//r2):End:Return r1*64//r2