• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows FPS and deltatime

Z

zendraw

Guest
So im trying to make a game run the max fps possible for the player`s display. a guy tells me that the game lags for him being 60fps with Vsynch. his monitor is 144hz

do i simply implement deltatime in the project or theres somthing else nececery?

for deltatime i assume 256 wuld be enough fps.
 
If your game is lagging, increasing the max FPS or adding delta timing isn't going to fix that. You'll have to find the source of the lag and optimize it in order to fix it.
 

NightFrost

Member
Delta time is not a tool to fix a laggy game. Delta time is a method of creating a game to be responsive to varying load on CPU and still have gameplay that appears to have a constant rate. (Necessity for delta time is partially invalidated by GMS running at fixed frames per second, so game will run at constant rate without delta time as long as a frame does not exceed the time allotted to it.) The idea is to measure time elapsed since last frame (thus: delta time) and use that as basis for current frame's actions. That is, you are not measuring frames, you are taking a measure of time and building your game ground up to adjust all movement and all timers by that measure.

For an observer (the player) looking at your game it would appear that even if the game ran at 60fps, or chugged along at 3fps for a moment, the rate of the player character's movement would at all times appear to be N pixels a second. At low fps this of course would look extremely choppy due to sparse screen updates, but the goal of delta time, in this case a constant movement rate over time, would be preserved.
 

Coded Games

Member
People here are not necessarily correct. The game may not be laggy, it's just running at a fixed 60 fps so your PCMR friend with a 144Hz monitor thinks it's laggy because it's just running at 60 fps. Delta timing can work both ways, it can make a laggy game look a little better but it can also allow games to run at much higher frame rates than originally intended. You can run the game at any frame rate.

So yes, if you want the game to be able to be ran at 144 fps without looking sped up you need to implement delta timing. You need to adjust your games room speed to 144, or like 9000 if you want completely unlocked FPS, and then modify everything in your game that moves to use delta timing. If you use GMS's built in alarm system you will have to make your own system instead. Depending on how far along your game is this can be an incredible amount of work to implement.

The other method would be to just create a frame rate multiplier. For example if 60 FPS is your base, add an option in the game to change room speed to 144 and then everything that moves you multiply its movement speed by 0.416667 = 60 / 144.
 
Last edited:

johnwo

Member
the game lags for him being 60fps with Vsynch
Do you mean that the game only runs at 60fps on his rig?
Do you use game_set_speed at any point?

Delta-time is something you use to calculate speed etc. based on fps. DT in itself won't make your game run at x fps for a rig that supports framerates of x hz.
 
Z

zendraw

Guest
im not sure really, after i set vsynch becouse of fading effects tearing tthe screen he complained that its laggy, i assume slow altho with me there was no diffrence. game speed doesnt change at no point, its set to 60fps and never changed.
the game is not laggy in the sense that it has bad code and is intensive, im sure it will run without a problem on my older pc which is 10+ years old and wasnt a peak machine at that time.

i assume now i shuld check the rate at which the monitor works and set the game speed to that, or i shuld just set a high room speed 256 and do the delta time thing?
 
R

robproctor83

Guest
Hmm... My understanding is that VSync should sync with the monitors refresh rate, not the room speed... but then if your setting the refresh rate to 144 and the room speed is 60 it will stutter. If you try adjusting the room speed to 144 to match the players monitor then that also won't work because it will then speed up your game by 2, which isn't what you want.

Ultimately, I think you will need to use delta time to achieve this, otherwise the solution would be for the user to set their refresh rate to 60 while playing the game. I don't know if you could possibly do that in code somehow, but I kind of doubt it. Unfortunately adding delta time will not be easy, especially if your already far along with your project. Delta time changes pretty much the way you calculate every variable, specifically variables that apply motion or that change over time. Things like particle systems, alarms, motion functions (like motion_add), speed related variables like image_speed, speed, friction and many many other things do not work with delta time and so you will need to rebuild them with your own custom systems. Every place you have an alarm set, or image speed, or object speed, etc all need to be rewritten entirely. Not to mention there are also things that just don't work with delta time at all, like physics or the built in particle system.

So, not trying to dissuade you, but it's important you understand how difficult a task like this will be. You will essentially be committing to rebuilding the game, from scratch. It may not be worth that if you are close to release, realistically how many users will be affected by this? Most all people are at 60fps.
 
Z

zendraw

Guest
the only things i culd think of that deltatime wuld affect are timers, regenerators, and motions. it wuldnt take that much time imo.
 
Top