Time Delay? 
Author Message
 Time Delay?

I use Quickbasic 7 with windows 95.

Recently, I copied some of my source code from some games I wrote
to my new computer, a Pentium 200mhz from a 486. When I compiled the
games, they ran extremely fast, making the game completely unplayable.

For the delays in the game, I used For Next commands, but I believe these
commands to be processor dependant. Is there any way to make time delays
in seconds or milliseconds, so it will be the same on almost any processor?

Thanks for any replies.
--^alleycat



Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

2072

-> I use Quickbasic 7 with windows 95.

-> Recently, I copied some of my source code from some games I wrote
-> to my new computer, a Pentium 200mhz from a 486. When I compiled the
-> games, they ran extremely fast, making the game completely unplayable.

-> For the delays in the game, I used For Next commands, but I believe t
-> commands to be processor dependant. Is there any way to make time delays
-> in seconds or milliseconds, so it will be the same on almost any proc

-> Thanks for any replies.
-> --^alleycat

Alleycat,

In Quickbasic you can read the number of seconds so what I did was to
put a for/next loop inside of a for/next loop, only going to the second
when x number of seconds passed in the first.

In my case the loop picked was a keyboard read so the for/next time loop
contained the reading of the keyboard whereas the calculations for the
event (a lunar lander) were external since they were in 1 second
resolution.

Perry



Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

This is definitely not the best way because you can't get too good
pauses but, it isn't processor dependant... (I think it isn't... stuff
ran at the same speed on my 33mhz and my 166mhz, so, that's proof
enough for me :))

sub pause(length#)
  start# = timer: while timer < start# + length#: wend
end sub

Then, in your code just do something like

pause 1   (would be a second)

or

pause .001 (if you want to get more accurate)

Hope this helps....

On 22 Jun 1998 15:32:07 GMT, "alleycat"

Quote:

>I use Quickbasic 7 with windows 95.

>Recently, I copied some of my source code from some games I wrote
>to my new computer, a Pentium 200mhz from a 486. When I compiled the
>games, they ran extremely fast, making the game completely unplayable.

>For the delays in the game, I used For Next commands, but I believe these
>commands to be processor dependant. Is there any way to make time delays
>in seconds or milliseconds, so it will be the same on almost any processor?

>Thanks for any replies.
>--^alleycat


http://www.thrillhaus.com/


Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

Yes, there is:

SUB Delay (DelayTime!)
  TimeOut! = TIMER + DelayTime!
  DO: LOOP UNTIL TIMER > TimeOut!
END SUB

This will make you able to have delays < 1 sec...(down to 55 ms i think i've
heard)..

-Thomas Daugaard

Quote:

>I use Quickbasic 7 with windows 95.

>Recently, I copied some of my source code from some games I wrote
>to my new computer, a Pentium 200mhz from a 486. When I compiled the
>games, they ran extremely fast, making the game completely unplayable.

>For the delays in the game, I used For Next commands, but I believe these
>commands to be processor dependant. Is there any way to make time delays
>in seconds or milliseconds, so it will be the same on almost any processor?

>Thanks for any replies.
>--^alleycat



Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

Quote:

> For the delays in the game, I used For Next commands, but I believe these
> commands to be processor dependant. Is there any way to make time delays
> in seconds or milliseconds, so it will be the same on almost any processor?

The following just came to my mind:
More accurate timing is often requiered, and this has been dealt with in
a couple of postings. When the timing is used for measurements the
(often complicated) suggestions are neccessary. However for delays in
games end the like, couldn't the following suggestion be formed into a
solution:
      As an initializing "statement", calculate what "for:next"-value is
needed to get
      a one-second delay. Store this value and use it throughout the
program to get
      millisecond-delays without complicate timer-functions.

   'Calculate one-second delay value:
   T# = timer
   HiGuess& = 0
   do while timer - t# < 1
      HiGuess& = HiGuess& + 1
   loop

   LoGuess& = HiGuess& \ 2
   DO While (LoGuess& / HiGuess& < .01) OR (HiGuess - LoGuess < 2)
      Guess& = LoGuess& + 1 + (HiGuess& - LoGuess&) \ 2
      T# = timer
      FOR I& = 1 TO Guess&
      NEXT
      T# = TIMER - T#
      IF T# <= 1 THEN
        LoGuess& = Guess&
      ELSE
        HiGuess& = Guess&
      END IF
   LOOP

   OneSecondDelayValue& = LoGuess&
   '
   'Now, use it wisely
   '
   N% = OneSecondDelayValue& / 1000
   FOR I% = 1 TO N%
   NEXT

Marnix.



Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

On 22 Jun 1998 15:32:07 GMT, "alleycat"

Quote:

>ing the game completely unplayable.

>For the delays in the game, I used For Next commands, but I believe these
>commands to be processor dependant. Is there any way to make time delays
>in seconds or milliseconds, so it will be the same on almost any processor?

milliseconds is difficult, but not impossible.

The standard timer resulution is 1/18th of a second.
If that resolution is good enough for you, you can use something like this.
(Notice: 1/18 sec. = 0.056. This is the step value that will be measured.)

SUB DELAY(secs!)
        TIM1!=TIMER
        WHILE TIMER <= TIM1! + secs!
        WEND
END SUB

Another method is measuring the vertical retrace. This gives you
approximately 1/70 of a second, but unfortunately it's not reliable under
windows.

WAIT &H3DA, 8
WAIT &H3DA, 8, 8

This will be approximately 1/70th second.

In a sub:

SUB DELAY(secs!)
        For T! = secs! * 70
                WAIT &H3DA, 8
                WAIT &H3DA, 8, 8
        Next T!
END SUB
--
Marc van den Dikkenberg
-----------------------
The powerbasic Archives
http://www.xs4all.nl/~excel/pb.html



Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

Quote:

>sub pause(length#)
>  start# = timer: while timer < start# + length#: wend
>end sub
>Then, in your code just do something like

>pause 1   (would be a second)
>or
>pause .001 (if you want to get more accurate)

Since the standard timer has a resolution of 1/18 of a seconds, 0.056
seconds is the most accurate you can get with this.

It won't make any difference if you tell it to wait 0.0000001 seconds or
0.055, the delay will be exactly the same duration.
--
Marc van den Dikkenberg
-----------------------
The PowerBasic Archives
http://www.xs4all.nl/~excel/pb.html



Fri, 08 Dec 2000 03:00:00 GMT  
 Time Delay?

It was the bright day of 22 Jun 1998 15:32:07 GMT when alleycat ran {*filter*}
through the streets of alt.lang.basic, chanting:

Quote:
> I use Quickbasic 7 with windows 95.

> Recently, I copied some of my source code from some games I wrote
> to my new computer, a Pentium 200mhz from a 486. When I compiled the
> games, they ran extremely fast, making the game completely unplayable.

> For the delays in the game, I used For Next commands, but I believe these
> commands to be processor dependant. Is there any way to make time delays
> in seconds or milliseconds, so it will be the same on almost any processor?

IIRC, there was an article on this in Basix Fanzine issue 10 -
http://www.*-*-*.com/

ee
--
Alex Warren, aka Emergency Exit

icq:   4043750

http://www.*-*-*.com/ ;          - Axe Software: freeware for DOS & Windows
http://www.*-*-*.com/ ;- Basix Fanzine: magazine for BASIC programmers
-----------------------------------------------------------------------------

to the email address above)



Sat, 09 Dec 2000 03:00:00 GMT  
 Time Delay?


<--snip-->
Quote:
> The standard timer resulution is 1/18th of a second.
> If that resolution is good enough for you, you can use something like
this.
> (Notice: 1/18 sec. = 0.056. This is the step value that will be
measured.)

> SUB DELAY(secs!)
>    TIM1!=TIMER
>    WHILE TIMER <= TIM1! + secs!
>    WEND
> END SUB

This is fine, and I have no problem with it, but I feel like being
pedantic, so I'll say that it's actually 1/18.2. Also, I found somewhere on
the Net which can do timing to microseconds, apparently, but I've no way to
time it. I'm pretty sure it's either at
http://www.pinn.net/~nunally/qbasic/qbasic.html or http://qbasic.com, both
great sites anyway.


Sat, 23 Dec 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Time delays and usual times

2. Time Delays

3. Time Delay, close current form, open new form

4. Time Delay within procedure

5. How to give Time delay in VBA

6. Micro-Second time delays...

7. Creating exact time delays

8. Timed Delay

9. Timed DELAY

10. Visual Basic timing/delays

11. Time delays in Qbasic?

12. Time Delay Loop

 

 
Powered by phpBB® Forum Software