Thanks Quel, that pushed me in the right direction, below is a revised version that scales using integers, the disturbing thing is what values end up in those integers:
REM test sprite scaling
sync on
rem build 2 sprites, bas size of 100x100
cls 0x301010
get image 1,0,0,100,100
sprite 1,100,100,1
cls 0x103010
get image 2,0,0,100,100
sprite 2,200,125,2
sync
SCALE# = 1 : lastscale# = 0
do
cls 0x2020ff
print "Scale = " ,SCALE#," int(Scale) = ",int(SCALE#)
print "xp1,yp1 = " ,xp1,",",yp1," : xs1,ys1 = ", xs1,",",ys1
print "xp2,yp2 = " ,xp2,",",yp2," : xs2,ys2 = ", xs2,",",ys2
rem scale
SCALE# = INT(SCALE# * 100.0) / 100.0
if SCALE# <> lastscale#
xp1 = 100 * SCALE# : yp1 = 100 * SCALE#
xs1 = 100 * SCALE# : ys1 = 100 * SCALE#
xp2 = 200 * SCALE# : yp2 = 125 * SCALE#
xs2 = 100 * SCALE# : ys2 = 100 * SCALE#
sprite 1,xp1,yp1,1
sprite 2,xp2,yp2,2
size sprite 1,xs1,ys1
size sprite 2,xs2,ys2
lastscale# = SCALE#
endif
if MOUSECLICK() = 1 then delete sprite 1: delete sprite 2 : lastscale# = 0
sync
loop
I noticed here that, when the gap appears at scale 1, although the printed scale shows as 1, doing an int on it gives zero, suggesting it is actually 0.9999999999....
Below is a fix, for this example at least, it keeps the SCALE to 2 decimal places, and resets it to 1 exactly when the scale is passing 1:
REM test sprite scaling
sync on
rem build 2 sprites, bas size of 100x100
cls 0x301010
get image 1,0,0,100,100
sprite 1,100,100,1
cls 0x103010
get image 2,0,0,100,100
sprite 2,200,125,2
sync
SCALE# = 1 : lastscale# = 0
do
cls 0x2020ff
print "Scale = " ,SCALE#," int(Scale) = ",int(SCALE#)
print "xp1,yp1 = " ,xp1,",",yp1," : xs1,ys1 = ", xs1,",",ys1
print "xp2,yp2 = " ,xp2,",",yp2," : xs2,ys2 = ", xs2,",",ys2
rem scale
SCALE# = CLAMP(SCALE# + (MOUSEMOVEZ() / 1000.0),0.16,3.04)
rem fix SCALE# to 2 decimal places
SCALE# = INT(SCALE# * 100.0) / 100.0
if SCALE# <> lastscale#
rem reset scale to be 1 when it passes the boundary of 1
if (SCALE# > 1 and lastscale# < 1) or (SCALE# < 1 and lastscale# > 1) then SCALE# = 1
xp1 = 100 * SCALE# : yp1 = 100 * SCALE#
xs1 = 100 * SCALE# : ys1 = 100 * SCALE#
xp2 = 200 * SCALE# : yp2 = 125 * SCALE#
xs2 = 100 * SCALE# : ys2 = 100 * SCALE#
sprite 1,xp1,yp1,1
sprite 2,xp2,yp2,2
size sprite 1,xs1,ys1
size sprite 2,xs2,ys2
lastscale# = SCALE#
endif
if MOUSECLICK() = 1 then delete sprite 1: delete sprite 2 : lastscale# = 0
sync
loop
RR
"Don`t try to engage my enthusiasm, I don`t have one"