Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

WaitVBL in VB5 ???

I'm attempting to write a game in Visual Basic 5.
I need to ensure the game play rate is consistent and not too fast. I used to use Blitz Basic 2 on the Amiga and it had a "WaitVBL" command that was used to wait for the screens next complete vertical blank. Is this possible to achieve this with VB 5 ? If not, is it possible to ensure that a game will play at roughly the same speed on (say ) a P133 and a PII 233 ? Obviously, FOR... NEXT loops are not acceptable ;) I notice other games have been written with VB5, so somebody else must have overcome this very problem.
0
lbowers
Asked:
lbowers
  • 4
  • 3
1 Solution
 
anthonycCommented:
You can use SLEEP API (see below) to pause things for a desired number of milliseconds.  You can also use DOEVENTS to have windows complete actions in it's queue, to slow down your game.

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal
dwMilliseconds As Long)

0
 
lbowersAuthor Commented:
Edited text of question
0
 
rmichelsCommented:
Unfortunately I don't think either Sleep or DoEvents will provide predictable periods.  Generally they provide a delay for a minimum amount of time, but exactly how long after that minimum it variable.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
lbowersAuthor Commented:
You're right - I've tried using both of the prviously mentioned solutions and they both vary wildly on the actual time they delay for. It looks like it's not going to be possible with delving into Direct X perhaps...
0
 
anthonycCommented:
SLEEP API delays for the number of milliseconds you specify.  Nothing more, nothing less.
0
 
lbowersAuthor Commented:
Anthony...

Sorry - You were right. The SLEEP API work perfectly!

How do I award you the points as I don't seem to be able to!
I can see no grading options either...
0
 
anthonycCommented:
You can give me points now!
0
 
lbowersAuthor Commented:
Thanx a million!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now