Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

Any wait function?

A topic by Jamie created Dec 16, 2016 Views: 2,963 Replies: 9
Viewing posts 1 to 6

How can my game wait or sleep for an amount of time?

Developer(+1)

'function TIC()' calls 60 times per second, so you can use code like this:

local t=0
function TIC()
    cls(12)
    t=t+1
    
    -- wait 2 seconds
    if t<2*60 then return end
    
    print("HELLO WORLD!",84,64)
end

Perfect, thanks mate

does this work on any other functions that arent function  TIC? i want a custom fuction to play an animation

Deleted 3 years ago
(1 edit)

in case you don't have a stable frame rate as you can use this

local t=0
pt=time()
dt=0
function TIC()
     dt=time()-pt
     pt=time()
     cls(12)
     t=t+dt
     -- wait 2000 miliseconds
     if t<2*1000 then return end
     print("HELLO WORLD!",84,64)
 end

um... waiting for music is refusing to work. I don't know why

Wow! it was that easy

Such a pity that javascript's setTimeout() doesn't function here...

async ={frames = 0}

function WaitForSeconds(secs)

async.frames = async.frames + 1;

if(async.frames >= secs *
consts.maxFrames)then

async.frames = 0

return true

end -- if async

return false

end

(-1)