by skydereign » Sat Apr 28, 2012 9:56 pm
The problem I believe has to do with casting. C truncates doubles and floats when casting into an integer. CollisionFree uses integer xy values, so we are dealing with some level of truncation. Now take the following two examples (your code to determine landing uses y+yvelocity+1, and your gravity is 0.16).
ball.y=-2;
y+yvelocity+1 = (-2) + (0.16) + (1) = -0.84 = 0
ball.y=-1;
y+yvelocity+1 = (-1) + (0.16) + (1) = 0.16 = 0
Notice how there is no difference between one pixel (along y=0). Because of this truncation, all negative values less than -1 of y will be a pixel offset from the same calculation dealing with positive values of y. This makes sense because truncation removes data, which will always make the number closer to 0.
To avoid this problem, you can force the actor to be a pixel lower, that way you aren't floating above, by switching +1 to -1 (a cheap hack, but one pixel floating above is far more obvious then one pixel lower in the collision).
-Edit
Fixed the example.