Simple timing problem
BlitzMax Forums/BlitzMax Beginners Area/Simple timing problem| 
 | ||
| I have a problem that I assume is very simple to solve and I might have just missed this tutorial, sorry in advance for the newbie question. I have a function that I want to execute a delay in, but I don't want to freeze the entire application in the process. example: function blah() do stuff delay 5000 do stuff 5000 later endfunction Of course, the delay command freezes execution on the entire application. I want to create delays in the function execuation that keep the rest of the app moving along. I've looked into timers, delay, and whatnot, but I don't think I'm doing it right. Any help would be great! Thanks! | 
| 
 | ||
| I' ve done an little library that deals with timers but it's for BlitzPlus/3D. You can still look at the code... alarm.bb | 
| 
 | ||
| Local Hold:int = Millisecs() + AmountToDelay 
While Not KeyHit(KEY_ESCAPE)
  'This part will be delayed until Millisecs() has reached the hold time
  If Millisecs() >= Hold
    DoStuff()
  End If
  'This part will always be executed
  DoOtherStuff()
Wend
 | 
| 
 | ||
| Or you can use a counter like below 
Local Hold:int = 1000 'in frames
While Not KeyHit(KEY_ESCAPE)
  'This part will be delayed until Hold is zero
  If Hold = 0 then
      DoStuff()
  Else
    Hold:-1 'reduce the frame counter
  End If
  'This part will always be executed
  DoOtherStuff()
Wend
 |