Tweens might help here. Unload all the work of moving the text onto the engine.
// Project: tween
// Created: 2019-09-28
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "tween" )
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
lines as string[] //This will hold the lines of our text
texts as integer[] //This will hold the text objects
//We will create some random lines to display
for i = 0 to 50
lines.insert('')
for j = 1 to random(10,40)
lines[i] = lines[i]+chr(random(65,91))
next
next
tween = CreateTweenText(10.0)
settweentexty(tween,798,-30,TweenLinear()) //from below bottom until top
delta as float
nextLine as integer = 0
delayrate as float = 0.8 //The amount of seconds between each line
delay as float = 0.8 //amount of time until the next line
do
delta = GetFrameTime()
dec delay,delta
if delay <= 0.0 //If time for next line
inc delay,delayrate
if nextLine <= lines.length //If not all the lines have been used
text = CreateText(lines[nextLine]) //Create and position the text
SetTextSize(text,50.0)
settextx(text,(1024-GetTextTotalWidth(text))/2)
SetTextY(text,798)
texts.insert(text)
PlayTweenText(tween,text,0) //Attach and start the tween
inc nextLine,1
endif
endif
for i = 0 to texts.length
if GetTweenTextPlaying(Tween,texts[i]) = 0 //Delete the text of any tweens not playing
DeleteText(texts[i])
texts.remove(i)
endif
next
UpdateAllTweens(delta)
print (nextLine)
Sync()
loop