realbasic-games
[Top] [All Lists]

Re: Timer Precedence (Using Multiple Timers)

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Timer Precedence (Using Multiple Timers)
From: Nick Lockwood <nick at charcoaldesign dot co dot uk>
Date: Mon, 28 Jun 2004 17:27:13 +0100
Delivered-to: realbasic-games at lists dot realsoftware dot com
List-help: <mailto:realbasic-games-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Games <realbasic-games.lists.realsoftware.com>
List-post: <mailto:realbasic-games@lists.realsoftware.com>
References: <02BC7581-BFE7-11D8-9248-000A95EED9D2 at comcast dot net> <0CE5AACD-BFEA-11D8-829B-000393101B4A at mobleybros dot com> <D8B94EFE-BFF1-11D8-BBD2-000A95CDD7B0 at charcoaldesign dot co dot uk> <6778211C-C074-11D8-829B-000393101B4A at mobleybros dot com> <3C8359BA-C8EC-11D8-9DB0-000A95CDD7B0 at charcoaldesign dot co dot uk> <FCF860D6-C918-11D8-95D8-000393101B4A at mobleybros dot com>
The way my timer is setup is to call the game loop once -- not multiple times.

Yes, that would be the normal way.

The performance is really good.

That depends on your expectations, and of course on what you are doing inside the loop. For a more or less empty loop that just refreshes the screen, I get about 50fps on my 1.25Ghz G4 PowerBook. That means that anything I actually draw or calculate will reduce the frame rate.

Basically, the way a timer is suppose to operate is it will fire at or after the time you specify in the period. If something else is going on, then it will not fire until that task has completed.

That is correct, however due to the internal implementation, the timer absoltutely will not fire more often than say 50fps even on the fastest hardware. During the time it is waiting, you cannot do any calculation or drawing (that is to say, anything you do will delay the timer). If you run it at about 30fps then you can do some stuff in your loop before you get performance degradation, but not a lot of stuff.

If you are getting really slow performance with the timer, it is more likely that your game loop is the cause -- optimize it a bit and you should see better performance with the timer.

Well, put it this way, in my game, with my loop firing once per timer cycle I get around 25fps with my game on my machine. With a tight loop I can get 200fps or higher.

With the empty loop I mentioned earlier, with the screen being refreshed every time around but not much being drawn, I get 1000fps in a tight loop, and still only 50 or so with a timer.

Timers waste a lot of time, quite simply. They are however undoubtedly the best solution available currently for games that require the user to be able to click menus, move windows, ect. That is why I have been struggling with ugly hybrids to try and get the best of both worlds.

On the original PowerBook G4 500 MHz with a pitiful 8 MB ATi RageM3 video card, I am getting an average of 50 fps in a sprite based game when I have the timer period set to 0 -- so effectively, my timer is really firing every 20 ticks.

Yes, that's fine, the problem is that with a much better machine you'll still get the same performance. Trust me on this, it's been discussed at length on this list if you check the archive.

I'm glad timers are working for you. 50fps is a quite decent frame rate and I myself have used timer for every project to start off with, however in my experience once you start cranking up the graphics in a game, that 50fps rapidly drops to below 30 at which point you need to explore other options. My machine can easily run games like Medal of Honour and Return to Castle Wolfenstein at an average of 60fps, it is ludicrous that simple games like Tetris cannot run this fast when written in RB.

Joe Strout alluded to a method of getting much better performance without the need for such hacks. I quote "...and there are other ways to get a good solid 150 fps or so (on my 733 MHz G4) while still being able to move the mouse, use menus, interact with controls, etc. However I'm not sure to what extent these ways work in 5.5.2 -- I'd check, but it's getting quite late and I need to get ready for a weekend trip. So again, I'm sorry to ask for a bit of patience on this issue."

But, that was a month ago and we've heard nothing since.

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>