• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - IDE 75Hz Display Studders When Fps is 60

T

Teramiiko

Guest
Hi there,

I have an Acer KG271 monitor that runs at 75Hz. It works fine with everything other than gamemaker. I've played games running at various frames per second with no issue. However, both GMS 1.4 and GMS 2 share a problem; games set to 60 fps (or anywhere from 1 - 143) studder. 144fps seems to work fine on both versions (and 75fps for GMS 2) however, I'm worried that it would be unwise to go ahead using those values.

They say there are no stupid questions, only stupid answers, but I'm sure that this is a stupid question.

How can I play gamemaker projects smoothly at 60fps? If that is not possible for some reason, what workaround could I use? I'm keen to purchase the full version of GM 2 but I must first iron out problems like this.

Thanks :)
 

kupo15

Member
Is vsync turned on? I may be wrong but 75Hz and 60fps doesn't go evenly together. If your monitor was say 120Hz it would line up as a multiple of 60. Vsync takes the fact that if the monitors are out of sync and waits until they sync. This is why your 75fps works perfectly since the game is synced up with the refresh rate of your monitor.
 
T

Teramiiko

Guest
Is vsync turned on? I may be wrong but 75Hz and 60fps doesn't go evenly together. If your monitor was say 120Hz it would line up as a multiple of 60. Vsync takes the fact that if the monitors are out of sync and waits until they sync. This is why your 75fps works perfectly since the game is synced up with the refresh rate of your monitor.
Thanks for your reply. That makes sense, however, how can I activate vsync? Gamemaker 1.4 and 2 only seem to manage vsync through display_reset, and fiddling round with that makes no difference.
 
L

Lonewolff

Guest
How can I play gamemaker projects smoothly at 60fps? If that is not possible for some reason, what workaround could I use? I'm keen to purchase the full version of GM 2 but I must first iron out problems like this.
Hi dude.

This can be easily fixed by careful design at the beginning.

This is how I go about it.
  • Set room_speed to 9999
  • display_reset(0, true)
  • Multiply your movement against delta_time
Doing this, your game will always have a frame rate of the monitor's refresh and movement speed will be the same regardless of the monitors refresh rate.

Also gives the benefit of smoother frames for those who have invested in a higher end monitor. They will love you for it :)
 
T

Teramiiko

Guest
This is how I go about it.
  • Set room_speed to 9999
  • display_reset(0, true)
  • Multiply your movement against delta_time
Thanks! There is definitely an improvement - it studders a lot less, but it still does, and now at uneven intervals depending on how fast objects are moving. Also, I had to divide by delta_time, as multiplying sent my player object into the stratosphere!

My creation code is;
Code:
room_speed = 9999;
display_reset(0, true);
My step event code is;
Code:
x += ( keyboard_check(vk_right) - keyboard_check(vk_left) )*5/delta_time;
y += ( keyboard_check(vk_down) - keyboard_check(vk_up) )*5/delta_time;
When five is changed, the studdering pattern changes. It's really annoying to look at. Am I missing something?
 
Last edited by a moderator:
T

Teramiiko

Guest
So, with a bit of fiddling around, It seemed to work perfectly. I used *delta_time/10000 for movement and it's silky smooth. Using draw_text(20, 20, fps), the game shows that it is running at 75 fps, which is great.

I compiled the project and ran it on a different pc, which has a monitor that runs 60 fps gamemaker games fine. The game showed that it was running at 60 fps, however, the actual game speed was a little bit slower.

How can I keep the games running smoothly on all devices while maintaining the same game speed?
 
L

Lonewolff

Guest
If the frame rate itself is stable, you could try dividing against room_speed instead.

Could be odd fluctuations in delta_time causing the sporadic behaviour.

Ah I see you ninja' my post :D
 
L

Lonewolff

Guest
The game showed that it was running at 60 fps, however, the actual game speed was a little bit slower.
When you say this, you mean the movement that you calculated delta_time with is slower or everything else?

Was movement itself the same speed on both PC's?
 
T

Teramiiko

Guest
Sorry, I should have clarified. The movement is affected. On PC1, the delta_time/10000 stays at around 1.35, while on PC2, it stays around 1.67.
 
L

Lonewolff

Guest
This is how I calculate things. Very similar to what you are allready doing.

Code:
x += move_speed * delta_time / 1000000;
If move_speed is 5. The sprite will move 5 pixels per second regardless of if the room_speed is equal to 10 or 1000.

Maybe the difference lies in the division amount, for some odd reason that I cant currently envisage.
 
T

Teramiiko

Guest
Ah, yes, I thought you'd notice that. See, when I try /1000000 movement slows to a crawl. It returns to normal if I multiply my movement speed value by 100, but the difference in game speed remains the same! Something else must be wrong.

Using draw_text(20, 50, delta_time/1000000); shows 0.01 on PC1 and 0.02 on PC2, which isn't very helpful.
 
L

Lonewolff

Guest
100 sounds about right. That means you should be getting 100 pixels per second movement if you are using * delta_time / 1000000.

Yeah, something odd going on for you then.

What if you turn of vSync (as a test) and vary the room speed from one extreme to another on your dev rig? Does the slowdown / speed up still occur? By rights it should behave the same.

(Just trying to narrow down what is going on)
 
L

Lonewolff

Guest
Not using 'alternate syncronisation method' in the game preferences? I only ask, as I have never used that setting and not 100% sure how it works. Might be throwing timing out, not really sure. Just a random guess that one.
 
T

Teramiiko

Guest
Alright, some observations from PC1:

room_speed: if set below 75, studders. If set at or above, silky smooth.

display_reset: seems to have no affect regardless of different arguments.

I may have found a workaround, but I'll need to test it on PC2:
Code:
if fps > 1
{ 
    x += ( keyboard_check(vk_right) - keyboard_check(vk_left) )*500*delta_time/1000000*(60/fps);
    y += ( keyboard_check(vk_down) - keyboard_check(vk_up) )*500*delta_time/1000000*(60/fps);
}
The reason it checks for when the fps is over 1, is because during the first few moments of the games, fps glitches and (60/fps) = 1.J
Sure, gamemaker.
Anyway I'm hoping that (60/fps) will keep movement speed the same across computers while playing at different fps.
 
Last edited by a moderator:
T

Teramiiko

Guest
Not using 'alternate syncronisation method' in the game preferences? I only ask, as I have never used that setting and not 100% sure how it works. Might be throwing timing out, not really sure. Just a random guess that one.
That seems to have no affect unfortunately.

Also, I tested the 'solution' on PC2, and (60/fps) = 1 which is what I wanted, however, movement was actually faster on PC2 than on PC1!

By the way, I really appreciate your help.
 
Last edited by a moderator:
T

Teramiiko

Guest
So far, all the object code consists of:

Create Event:
Code:
room_speed = 9999;
display_reset(0, true);
Step Event:
Code:
if fps > 1
{
    x += ( keyboard_check(vk_right) - keyboard_check(vk_left) )*500*delta_time/1000000*(60/fps);
    y += ( keyboard_check(vk_down) - keyboard_check(vk_up) )*500*delta_time/1000000*(60/fps);
}
Draw Event:
Code:
draw_self();
draw_text(20, 20, fps);
draw_text(20, 50, delta_time/1000000);
draw_text(20, 80, 60/fps);
draw_text(20, 110, 500*delta_time/1000000*(60/fps));
 
Last edited by a moderator:
L

Lonewolff

Guest
Yeah, your step event didn't work well for me either.

Try this. This works fine for me, regardless of what room_speed is set to.

Code:
if fps > 1
{
    x += ( keyboard_check(vk_right) - keyboard_check(vk_left) ) * 500 * delta_time /1000000;
    y += ( keyboard_check(vk_down) - keyboard_check(vk_up) ) * 500 * delta_time /1000000;
}
 
T

Teramiiko

Guest
It works! I don't know what's different, but it works. For now at least. On both PCs, the player moves at the same speed across the screen. It sounds a bit silly, but I used a stopwatch to confirm this. Thank you so much.

Create event:
Code:
room_speed = 9999;
spd = 0;
Step Event:
Code:
if fps > 1
{
    spd = 500 * delta_time /1000000;
   
    x += ( keyboard_check(vk_right) - keyboard_check(vk_left) ) * spd;
    y += ( keyboard_check(vk_down) - keyboard_check(vk_up) ) * spd;
}
During the first second of the game, the fps starts at 60 no matter what, but I can deal with that.
 
T

Teramiiko

Guest
My next question would be, how can I correctly implement it into a platformer game?
I created a script, delta_time_fix(value)
Code:
if fps > 1
{
    return argument0*delta_time/1000000;
}
I've played around with the script using this code with slight alterations, however movement is never quite the same on PC1 and PC2.

Movement speed is the same, but applying gravity is giving me a hard time. Jump height is never the same on both PCs.
Code:
key_right = keyboard_check(vk_right);
key_left = keyboard_check(vk_left);
key_jump = keyboard_check(vk_up);

hsp = (key_right - key_left) * movespeed;
 
if (place_meeting(x,y+1,obj_m1_solid))
{
    vsp = key_jump * -jumpspeed;
}
else
{
    vsp += grav;
}

if (place_meeting(x+delta_time_fix(hsp),y,obj_m1_solid))
{
    while(!place_meeting(x+sign(delta_time_fix(hsp)),y,obj_m1_solid))
    {
        x += sign(delta_time_fix(hsp));
    }
    hsp = 0;
}
x += delta_time_fix(hsp);
 
if (place_meeting(x,y+delta_time_fix(vsp),obj_m1_solid))
{
    while(!place_meeting(x,y+sign(delta_time_fix(vsp)),obj_m1_solid))
    {
        y += sign(delta_time_fix(vsp));
    }
    vsp = 0;
}
y += delta_time_fix(vsp);
 
Last edited by a moderator:
Top