Posts: 12
Threads: 3
Joined: Jul 2003
how do i time things with a timer or something like animations, rotations, enemys movements and stuff?
nthlon 1800+ OCed to 2800+ speeds
512 mg of crucial pc3200 ram
Radeon 9600 pro
.......
I know that computer is complete overkill for qb but hey, who cares
Posts: 3,288
Threads: 167
Joined: Nov 2001
Posts: 1,272
Threads: 36
Joined: Feb 2003
TIMER give you the number of seconds that have passed since midnight. You can use it to time just about anything. It's only limitation is that it changes only about 18 times a second, so it won't work if you want to do something at a higher frequency than that.
Example:
Code:
INPUT "How many seconds do you want to wait?", seconds
timeToWaitFor! = TIMER + seconds
DO: LOOP UNTIL TIMER >= timeToWaitFor!
Many qb game programming libraries, such as directQB, UGL, and Future.Library come with timing routines that are better suited for animation etc. I'd suggest you check one of them out (I'd recommend DirectQB only because it's the best documented) and read it's manual and learn how to use it's timing routines.
Posts: 788
Threads: 53
Joined: Nov 2002
Best documented, pfffft.
oship me and i will give you lots of guurrls and beeea
Posts: 4,307
Threads: 63
Joined: May 2003
Well atleast its best among the documented libraries =P
Posts: 2,020
Threads: 24
Joined: Jun 2002
If you're using a library solely for its timing routines, you might as well use Seav's routine that changes the timer's refresh rate:
Code:
FUNCTION CLOCK&
' Get the number of timer ticks at
' 0000:046C
DEF SEG = 0
Ticks& = PEEK(&H46C)
Ticks& = Ticks& + PEEK(&H46D) * 256&
Ticks& = Ticks& + PEEK(&H46E) * 65536&
DEF SEG
' Latch the counter and obtain the PIT
' countdown status.
OUT &H43, &H4
LSB = INP(&H40)
HSB = 255 - INP(&H40)
' Compute the CLOCK& value
CLOCK& = Ticks& * 256& + HSB
END FUNCTION
to test it:
CLS
DO
TimerVal! = TIMER
ClockVal! = CLOCK / 4660.859#
LOCATE 1
PRINT USING "CLOCK: #####.###"; ClockVal!
PRINT USING "TIMER: #####.###"; TimerVal!
LOOP UNTIL LEN(INKEY$)
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry