Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to time things
#1
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
Reply
#2
TIMER
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#3
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.
Reply
#4
Best documented, pfffft.
oship me and i will give you lots of guurrls and beeea
Reply
#5
Well atleast its best among the documented libraries =P
Reply
#6
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)