realbasic-games
[Top] [All Lists]

Re: Thread behavior and priority in RB 5.2 vs 5.5

To: "REALbasic Games" <REALbasic-Games at lists dot realsoftware dot com>
Subject: Re: Thread behavior and priority in RB 5.2 vs 5.5
From: Nick Lockwood <nick at charcoaldesign dot co dot uk>
Date: Sat, 17 Apr 2004 10:53:51 +0100
References: <000501c423ed$53c1d610$2f0e4f18 at kwxgkx5y8sd746>
I was thinking of using a loop and do events with no thread but the whole Idea of this engine is that version 2 (maybe released by fall with a
game I am working on) will support network play.

Forget DoEvents, it wasn't designed for this and it will kill performance dead. If you want 30fps then a timer should be fine. If you want much higher than 30 fps then you'll need a tight loop and you'll have to handle events yourself as best you can.

What I have taken to using is a loop within a timer event. The Timer is set to loop at 30fps. If the user presses any significant key combinations (command-q for example) or clicks the mouse in the vicinity of the menu bar then the tight loop exits. This means you get a decent fps during gameplay, and 30fps or so when the user is doing something that needs OS attention. This seems to work pretty well.

Threads are really no good for games because you have no control over how much of the cpu they get. They also seem to vary wildly in their performance from one RB version and OS to the next.

For what it's worth, I always thought using a timer was the way to go, but in my experiments with doing OpenGL stuff lately, my project performance went from around 25fps with a timer to 1000fps with a tight loop. Some more precise measurements of timing revealed that when using a timer, something in the region of 95% of the cycle was spent outside the event loop - in other words the timer (which was set to the minimum period) spent 19 times longer waiting to execute than it did executing the entire game loop.

Nick


- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>