Update a timer while wait_event is waiting?
BlitzMax Forums/BlitzMax Beginners Area/Update a timer while wait_event is waiting?
| ||
I have a timer in my game that I need to update each cycle but the Wait_Event is obviously waiting for mouse input. How update my timer to display in realtime while waiting for an event? |
| ||
PollEvent is working...I did it again... Anywho, since CurrentTime() returns the time in a string anyone know how to use this to make a timer but not have to parse the string and do the math manually? Trying to make a simple timer base on the clock. As in: New_Time = CurrentTimer() - Start_Time |
| ||
I'm an novice for sure, but can't you create an Event with createTimer(60) And look for the Event EVENT_TIMERTICK |
| ||
You mean as with MilliSecs() which is the one you might want to use for timing stuff. |
| ||
I mean for just doing a simple timer showing hours:minutes:seconds. I'd like to use the CurrentTime() var somehow. |
| ||
Graphics 640,480,0,0 While Not KeyDown(KEY_ESCAPE) Cls Local Time:TList = SplitString(CurrentTime(), ":") Local hours:Int = String(Time.ValueAtIndex(0)).ToInt() Local minutes:Int = String(Time.ValueAtIndex(1)).ToInt() Local seconds:Int = String(Time.ValueAtIndex(2)).ToInt() DrawText(hours+" : " + minutes + " : " + seconds, 10, 10) Flip Wend Function SplitString:TList(inString:String, Delim:String) Local tempList : TList = New TList Local currentChar : String = "" Local count : Int = 0 Local TokenStart : Int = 0 If Len(Delim)<>1 Then Return Null inString = Trim(inString) For count = 0 Until Len(inString) If inString[count..count+1] = delim Then tempList.AddLast(inString[TokenStart..Count]) TokenStart = count + 1 End If Next tempList.AddLast(inString[TokenStart..Count]) Return tempList End Function |
| ||
TTimer objects (retruned by CreateTimer) fire off events, so should break "WaitEvent"SuperStrict Graphics 32,32 Local myTimer:TTImer = CreateTimer(1) While EventID() <> EVENT_KEYDOWN WaitEvent If EventID() = EVENT_TIMERTICK Print "Timer has ticked " + TimerTicks(myTimer) + " times" EndIf EndWhile |