Improved it abit, but still not perfect.
Need to make a direction change detection, that does not go bananas when reading a finger on a touch device, it quickly jumps between the states, if I try to read direction change from last read, might need to set up an array of readings, then analyze them in realtime... So this code does not take into account direction change while not releasing the screen.
//
// AGK Application
// Scroll test
//
setvirtualresolution (1280,800)
setclearcolor (0,0,0)
setbordercolor (0,0,0)
setorientationallowed (0,0,1,1)
setresolutionmode (1)
setsyncrate (60,1)
setprintsize(24)
f=255
for s=601 to 700
createsprite(s,0)
setspritesize(s,256,256)
setspritecolor(s,f,f,f,255)
setspriteposition(s,-5000,-5000)
dec f,16
if f<64 then f=255
next x
offsetX#=640.0
movespeed#=0.0
startclick=0
distance=100
diff#=0.0
starttime#=0.0
timediff#=1.0
do
// Draw sprites
for x=1 to 50
setspritepositionbyoffset(x+600,offsetX#+(x*288),300)
setspritepositionbyoffset(x+650,offsetX#+(x*288),588)
next x
// Do calculations of movement from inertia
offsetX#=offsetX#+movespeed#
// Force limitation of start and stop offset values
if offsetX#>640.0 then offsetX#=640.0
if offsetX#<-14250.0 then offsetX#=-14250.0
// To do when if screen is first pressed
if getpointerpressed()=1
startclick=getpointerx()
diff#=offsetX#
starttime#=timer()
endif
// To do while screen is pressed
if getpointerstate()=1
offsetX#=diff#-(startclick-getpointerx())
endif
// To do when screen is released
if getpointerreleased()=1
distance=getpointerx()-startclick
timediff#=timer()-starttime#
movespeed#=(distance/timediff#)/80
endif
// Apply "friction"
if movespeed#>0 then movespeed#=movespeed#-0.05
if movespeed#<0 then movespeed#=movespeed#+0.05
// Apply full stop at very low speed (drif prevention)
if movespeed#>0 and movespeed#<0.05 then movespeed#=0.0
if movespeed#<0 and movespeed#>-0.05 then movespeed#=0.0
// Print diag data
printc("OffsetX: ")
print(offsetX#)
printc("The mouse moved: ")
print(distance)
printc("In so many seconds: ")
print(timediff#)
printc("Speed in pixel/sec: ")
print(distance/timediff#)
printc("Movespeed: ")
print(movespeed#)
// Draw all
sync()
loop
----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.