Re: Text which appears gradually
Posted: Sat Jul 08, 2023 12:18 am
Lovely riddle in the evening.
My approach:
My approach:
Code: Select all
C={{1,1,1,1},{1,0,0,1},{1,1,1,1},{0,1,0,1},{.2,.5,.9},{1,.1,1}}
Text = {'This text is',' red ','and then white.',"and green"," and whatever\n","NRNSSNRSNRSZNZrtineaortdaeonrtdeiaondtreatnrdodtrenaotndr"}
Speed=10
T=0
Position1=1
Position2=0
TT={C[1],""}
function love.update(dt)
T=T+dt*Speed
if T>1 then
T=T-1
Position2=Position2+1
if Position2>#Text[Position1] then
Position1=Position1+1
Position2=1
if not C[Position1] then
love.update=nil
return
end
table.insert(TT,C[Position1])
table.insert(TT,"")
end
TT[Position1*2]=TT[Position1*2].. string.sub(Text[Position1],Position2,Position2)
end
end
function love.draw()
love.graphics.print (TT,10,0)
end