rem rem AGK Application 1.08 Beta 16 rem Tick t#=timer() h#=random(1,10) do if timer()-t#>1.0 t#=timer() h#=random(1,10) endif Print(h#) sync() loop
rem rem AGK Application 2017.01.09 rem MR Do a#=timer() //seconds Print(a#) ShowTime(a#) print("Loop") sync() Loop Function ShowTime(sec as float) local min as Float min = trunc(sec / 60.0) sec = sec - min * 60.0 local ms as Float ms = sec - trunc(sec) ms = ms * 100.0 sec = trunc(sec) print(right("00"+str(min,0),2)+":"+right("00"+str(sec,0),2)+"."+right("00"+str(ms,0),2)) EndFunction
// a delay function by seconds function Delay(seconds#) ResetTimer() repeat Sync() until Timer() >= seconds# endfunction
// AGK 2017.05.15 (Tier1 Basic) // MR 24.05.2017 // multiple timer SetSyncRate(10,0) type TTimer beep as integer m as float endtype Main() end Function Main() local ping as TTimer[2] TimerInit(ping) local i as Integer Do Print("timer 1,2,3 seconds") TimerUpdate(ping) if ping[0].m => 1.0 TimerReset(ping[0]) ping[0].beep = 1 else ping[0].beep = 0 endif if ping[1].m => 2.0 TimerReset(ping[1]) ping[1].beep = 1 else ping[1].beep = 0 endif if ping[2].m => 3.0 TimerReset(ping[2]) ping[2].beep = 1 else ping[2].beep = 0 endif for i = 0 to ping.length print(ping[i].beep) next sync() Loop EndFunction Function TimerInit(ping ref as TTimer[]) local i as Integer for i = 0 to ping.length TimerReset(ping[i]) next EndFunction Function TimerUpdate(ping ref as TTimer[]) local i as Integer for i = 0 to ping.length ping[i].m = ping[i].m + GetFrameTime() next EndFunction Function TimerReset(ping ref as TTimer) ping.m = 0 EndFunction