Something with SetPhysicsScale and StepPhysics is not adding up.
I am assuming that Box2D is defaulting to 10 m/s^2 for the y acceleration. If this is the case, then an object released from rest will fall 5 m.
I setup a small program to do just that.
+ Code Snippetsetvirtualresolution(480,320)
loadimage(1, "ball.jpg")
createsprite(1, 1)
setspriteposition(1,100,0)
setspritephysicson(1, 2)
time = timer()
do
print(timer() - time)
print(getspritey(1))
sync()
if (timer() - time) >= 1
repeat
until getpointerpressed() = 1
endif
loop
end
According to the program, the ball falls around 15 pixels. If 5 m corresponds to 15 pixels, then the default scale is 0.333 m/pixel. According to the help file for SetPhysicsScale, the default is 0.2.
Since the physics is done numerically, I thought it may be a problem with the step size. I called StepPhysics with progressively smaller values. Two things should have occured. 1) If the step size was too large to begin with, the result of the calculation should change and then converge to a new value. 2) The simulation should take longer and longer to run. I didn't observe either of these.
There seems to be multiple inconsistencies. Can anyone resolve these?