Delay 1?

Miscellaneous Forums/General Discussion/Delay 1?

WaitEvent() accomplishes the same thing if you develop your game using timers (which is good practice anyhow).

local timer:TTimer = CreateTimer(60)

while(not(keydown(KEY_ESCAPE)))
     waitevent()
     if EventSource() = timer then
           ' do stuff
     end if
wend


that's one way of doing it with timers. EventSource() isn't as reliable as I've found when you have multiple things ticking/polling. So an alternate way is...

local timer:TTimer = CreateTimer(60) ' your main loop now runs at 60 ticks per second.
local lastTicks:int = 0
while(not(keydown(KEY_ESCAPE)))
     waitevent()
     local ticks:int = timerTicks(timer)
     if ticks > lastTicks then
           ' do stuff
           lastTicks = ticks
     end if
wend


Both ways return control back to the OS, and your CPU isn't running at 100% anymore. IMO, using timers and waitEvent is a good setup for most games made in blitz and using Delay(x) just seems hacker-ish to me.