Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Consistent frame rate/movement across systems

Author
Message
Lampton Worm
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 27th Oct 2003 15:21
Hi there,

I know there are have been posts on this past and present but I'm wondering what the consensus is on doing the best you can to ensure you games runs as best it can across different hardware specs. If there are any new thoughts on this please post (last time I looked there wasn't any definate answer as to how reliable the sync was, and also if the timer() was consistent between 9x and XP).

Thanks in advance.
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 27th Oct 2003 15:53
Try my code in code snippets forum

http://www.thegamecreators.com/?m=forum_view&t=18986&b=6

Have tested only on WinXP using various screen modes, fullscreen exclusive, windowed, and forcing various sync rates and 'seems' to work. Have used it for a few projects with no problems.

If your mansion house needs haunting, just call Rentaghost!
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 27th Oct 2003 15:59 Edited at: 27th Oct 2003 16:04
Timer relates you the system clock, it's not OS/system specific. I.e. 1000 millisecnods ='s 1 second on any platform.

Sync will only hold your frame rate bellow, or to a particular level. So it's only useful for holding the rate down on faster systems. The moment a frame runs long, the player will feel the frame rate drop. Your movement/animation etc will suffer


In DB/DBpro there's two solutions that come to mind. Both have pro's and cons

1) Scale movements/rotations based upon the frame rate/ length of frame (tie to render/update the frame..)

* Pros
- Fairly simple to implement.
- Will keep the appearance of a solid fps on machines capable of it.
- Allows you to run at Sync 0

* Cons

- All animation/movements/patterns etc must be time based to remind true. A good example of a common issue is when you need to an object to flow a path/pattern. You'd have to step through your path, updating any turns/junction points relevant, to the passed time period..

- Collision - You CAN'T USE REGION BASED COLLISION.. Making it virtually useless in DB/DBPRO. If you've noticed while playing some demo that you fall through floor, or walk through walls etc etc, it prolly attempts to approximate FPS in this fashion. So then You've seen this classic issue first hand. The problem occurs when either the machine can't hold the FPS at the games required clock, or simply drops when a frame runs too long. So what happens is when the game calculates the objects next position, it never takes into account that this movement may have stepped the object passed/through another object(s). Normally this happens with Small fast moving objects or, Thin ones like walls.. So the key point is, if you want it to be solid on slower machine, check for intersects... Normally if the game updates based on the timer, all collisions are ray based..


2) Manage the updates in passes. Pass 1 updates game logic (only) and then pass 2 renders the scene. When a frame runs long, you calc how many potentials frames have passed, then update the game logic accordingly (ie. if 2 frames have passed, you update the logic twice then render)

* Pro's

- Allows for regional collisions
- Gives a solid frame rate. So you actually get X frames (give you take) per second.
- Allows you to run at a Sync rate of 0


* Cons

- requires a specific design towards it's implementation
- May requires you manual calculate collision/ or values that only returnable after a render..



There's a third hybrid idea. Where you can update certain objects/effects using the timer (#1) (stuff without collision) and then manage your 'hard' objects through concept #2

Kevin Picone
Play Basic - Visible Worlds - Kyruss II
[url]www.underwaredesign.com[/url]
Genesis Rage
22
Years of Service
User Offline
Joined: 5th Oct 2003
Location:
Posted: 27th Oct 2003 16:18
i havent made much... and dont claim to be any good at this whole DarkBASIC thing... but what i have done in the past is have the game run at 30 fps 'sync 30' and using manual 'sync' or 'fastsync' commands at the end of my main loop... i set the game to run normal at 30 fps... but also give the chance to set 'sync 60' when this command is activated, everything is cut in half... (PlayerSpeed=0.5 instead of 1)

the downfall of this if the fps drops drastically below 30... which in turn slows the game down... messes up animation... etc... but honestly... i have NEVER seen a game that will update correctly and componsate for dropped fps due to system specs...

im not saying that this is impossible... nothing is impossible... but if componsating for a weak system was an easy-to-do task... Half-Life 2 and Doom 3 would be able to be played on a 386 proccessor!

==Main Computer==
Athlon XP 3000+, 1024mb, Radeon 9800 Pro 128mb 8xAGP, XP Pro
Lampton Worm
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 27th Oct 2003 18:42
Some very interesting points there Kev, certainly got my brain thinking (and that takes some doing these days ). Perhaps I should have a minimum hardware spec requirement, and lock the FPS. That takes care of the rendering/FPS side. Then I'd need a seperate timer based calculation for my time critical events, such as my key entry buffer or the player movement over time, animation speed etc. I have a buffer system for move combo input and while the balance is good on my system, it may be too strict on a faster machine. I think some experimentation is in order I take it people have these issues in other languages such as C++/VB?
zman
22
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Madison, WI USA
Posted: 29th Oct 2003 07:19
Well FWIW I've been playing around with using QueryPerformanceCounter instead of Timer()
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=18614&b=1&p=0

And yeah I think you'd run into these issues regardless of the programming language you choose. I worked my way through "Computer Game Programming with DirectX 8.0" by Ian Parberry...the code in that book is all in C++ but again he's using timer functions to keep the animation consistent across different computers.
Lampton Worm
23
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 29th Oct 2003 12:24
Thanks zman, I didn't see that post, will check out the DLL.

Login to post a reply

Server time is: 2026-07-26 16:04:16
Your offset time is: 2026-07-26 16:04:16