ok it is because you're moving in 1 increments (integers) during the collision checks but you could start less than 1 above the platform due to falling / moving in floats.
if puzzler's solution doesn't help you likely want to check when the collision happens and then move in smaller amounts till it is more precise to where you want it (or use the physics and let it work out the point of impact).
something like this (press space to reset the cube to a new random height to fall from)
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Steering test" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
cube = CreateSprite(0)
SetSpriteSize(cube,100,100)
temp# = Random2(1,2)
temp# = temp# * 0.1
startingY# = 190+temp#
SetSpritePositionByOffset(cube,512,startingY#)
SetSpriteShape(cube,2)
SetSpriteColor(cube,255,0,0,255)
ground = createSprite(0)
SetSpriteSize(ground,1000,100)
SetSpritePositionByOffset(ground,512,305)
SetSpriteShape(ground,2)
do
if GetRawKeyState(32)
temp# = Random2(1,50)
temp# = temp# * 0.1
startingY# = 190+temp#
SetSpritePositionByOffset(cube,512,startingY#)
endif
print(temp#)
Print("starting Y = "+str(startingY#))
if GetRawKeyReleased(27) then end
if GetSpriteCollision(cube,ground) = 0
SetSpritePosition(cube,GetSpriteX(cube),GetSpriteY(cube)+1)
endif
while GetSpriteCollision(cube,ground) = 1
SetSpritePosition(cube,GetSpriteX(cube),GetSpriteY(cube)-0.01)
endwhile
Print("cube y = "+str(GetSpriteY(cube)))
sync()
loop
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu