GLBasic forum

Main forum => GLBasic - en => Topic started by: Amon on 2009-Dec-27

Title: GetTimerAll Fandango? :)
Post by: Amon on 2009-Dec-27
Here's my code below. I'm trying to move a block 16 pixels across the screen every 5 seconds. In blitzmax I used the millisecs command but I'm not too clued up on GetTimerAll and how it works. Any help would be appreciated. :)

Code (glbasic) Select

FUNCTION MoveTopBlock:

TBlockTimer = GETTIMERALL()

DRAWSPRITE 0, TBlockX, TBlockY
IF TBlockTimer >= (GETTIMERALL() / 1000) - (GETTIMERALL() + 5000)
TBlockTimer = GETTIMERALL() / 1000
TBlockX = TBlockX +16
ENDIF

PRINT TBlockTimer,0,0
ENDFUNCTION
Title: Re: GetTimerAll Fandango? :)
Post by: matchy on 2009-Dec-28
Search on the forum for FPS (frames per second) for some tips!
Title: Re: GetTimerAll Fandango? :)
Post by: Schranz0r on 2009-Dec-28
a simple code:

Code (glbasic) Select

LOCAL TBlockX = 100

WHILE TRUE

IF Timer < GETTIMERALL()
INC TBlockX,16
Timer = GETTIMERALL() + 5000
ENDIF

PRINT DrawDebugTimer(),10,10
PRINT "TEST", TBlockX, 100

SHOWSCREEN
WEND
END




FUNCTION DrawDebugTimer:
LOCAL timer

timer = MOD(GETTIMERALL(),5000)
RETURN timer

ENDFUNCTION
Title: Re: GetTimerAll Fandango? :)
Post by: Amon on 2009-Dec-28
Thanks, Schranz0r. It works Perfectly. :)
Title: Re: GetTimerAll Fandango? :)
Post by: Schranz0r on 2009-Dec-30
no problem :)