Frame limitation?

BlitzMax Forums/BlitzMax Beginners Area/Frame limitation?

spacerat(Posted 2007) [#1]
Hi, I am new to Blitzmax and also to more complicated programming languages in general (I moved from GameMaker...). I am enjoying it so far, but there is one thing I need help with.
One thing I have noticed is that the game speed seems to change if I change the refresh rate of the game, the whole game speed changes. What I would like to know how to do first is make it so that I can frame limit the game, yet still keep the refresh rate high enough. The main reason for this is to prevent tearing in windowed mode (I can just use vsyncing in fullscreen).

Thanks in advance for any help.


Dreamora(Posted 2007) [#2]
There are different ways to achieve a constant game speed, the most used you will find on these boards is frame dependant code, which scales the amount of changes to the time passed.

Against tearing, there is only flip 1 that helps, BUT only if the user has not vsync disabled in his drivers. In that case, you can't do anything against it.


spacerat(Posted 2007) [#3]
I was also thinking about doing frame dependant code but I'm not totally sure how I would go about doing it. Also I saw that "dynamicgame.bmx" script in the Digesteroids example. If I were allowed to use that, would that be of any use?


JazzieB(Posted 2007) [#4]
There are two main methods used to ensure that a game runs at the same speed on all PCs. These are as follows.

1. DELTA TIMING - Basically, the amount of time passed between one frame and the next is used to calculate the amount that each game object should move in the next. This was what Dreamora was referring to.

2. FIXED-TIMED LOGIC - You basically separate the logic (update) code from the rendering code and have the game update a certain numnber of times a second. Usuaully a logic rate of 200 FPS or more yields better/smoother results. This is more suited to faster paced games. This is the method that I use.

3. A combination of both of the above. Gives the best results, but I personally think that one or the other of the above is enough (and so do a lot of commercial and/or indie developers). The end-user won't even notice the extra smoothness, but they will notice if a game suddenly starts to run a lot quicker than it should after an upgrade.

I won't go into the details here, as a search for the terms above will give you the answers you seek.

No doubt Grey will be along soon with another pimping of his framework ;o) J/k Grey.


spacerat(Posted 2007) [#5]
I think Fixed Logic is what I will do. I sort of have an idea of how to do it (timer object?) but I'm not sure enough. This might sound a bit noobish, but could someone possibly point me to a post which shows how to do it, or give an example?
Many thanks again.


TomToad(Posted 2007) [#6]
I believe Grey Alien posted his fixed rate code in the archives somewhere.

Edit: I thought for sure he posted the code somewhere, but I can't seem to find it.


Grey Alien(Posted 2007) [#7]
/pimp mode engaged. No not really, have a look at this: http://www.gaffer.org/game-physics/fix-your-timestep/

If that's too much then try Delta Time, a search should reveal many good examples. I may have posted the fixed rate logic a few times but I don't where, sorry, try a search,

Don't rely on vsync in full-screen mode as some people have it turned off.

Also I think Dreamora meant "frame INdependent code" as your code is currently frame dependent and you need to change it.

Finally check out my framework ;-)