• 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!

GameMaker Vsync

K

Kyle Rider

Guest
Hey everyone

Putting this in my rm_boot makes the game start really tiny. I want to give the option of having Vsync on and off. when is the best time to turn off vsync?

display_reset(global.aasetting, global.vsyncsetting);
 

RangerX

Member
It have nothing to do with the size of your game. Show me your Room Boot code.
And you can try something already, use display reset because resizing anything.
 
K

Kyle Rider

Guest
Code:
//OPEN INI FILE//
/////////////////
ini_open("settings.ini");

//AUDIO//
/////////
global.ambientSound = ini_read_real("sound", "ambient", 50);
global.effectSound = ini_read_real("sound", "effect", 50);
global.musicSound = ini_read_real("sound", "music", 50);

//VISUAL//
global.fullscreen = ini_read_real("Fullscreen", "fscreen", true);
global.aasetting = ini_read_real("AntiAlias", "aasetting", 0);
global.vsyncsetting = ini_read_real("VSync", "vsyncsetting", true);


//INITIALIZE INPUT GLOBALS//
////////////////////////////

//DIRECTIONS//
//////////////
global.key_up = ini_read_real("controls", "up", keyboard_get_map(vk_up));
global.key_down = ini_read_real("controls", "down", keyboard_get_map(vk_down));
global.key_right = ini_read_real("controls", "right", keyboard_get_map(vk_right));
global.key_left = ini_read_real("controls", "left", keyboard_get_map(vk_left));


//BUTTONS//
///////////
global.key_jump = ini_read_real("controls", "jump", keyboard_get_map(ord ("W")));
global.key_item = ini_read_real("controls", "item", keyboard_get_map(ord ("S")));
global.key_attack = ini_read_real("controls", "attack", keyboard_get_map(ord ("D")));
global.key_special = ini_read_real("controls", "special", keyboard_get_map(ord ("A")));
global.key_gpause = ini_read_real("controls", "gpause", keyboard_get_map(ord ("E")));

//Player variables//
////////////////////
global.phpmax = ini_read_real("MaxHealth", "phpmax", 6);
global.php = ini_read_real("CurHealth", "php", 6);
global.dir = ini_read_real ("Direction", "dir", 1);
global.player_pos = ini_read_real("Position", "player_pos", 0.0);
global.px = ini_read_real("Player_X", "px", 128);
global.py = ini_read_real("Player_Y", "py", 832);
global.roomx = ini_read_real("Room X", "roomx",3);
global.roomy = ini_read_real("Room Y", "roomy",2);
global.u_item = ini_read_real("Item Icon","u_item", 0);
global.end_dialog = false;
global.compass = 0;
global.vstory = 0;
global.dimvar = 0.8;


//INVENTORY//
/////////////

//SKILLS//
global.has_dbljump = 0;
global.has_trpjump = 0;
global.has_charge = 0;
global.has_dash = 1;

//ITEMS//
global.has_glowurm = 0;
global.has_gloves = 0;
global.has_vortex = 0;
global.has_bomb = 0;

//STONES//
global.has_windstone = 0;
global.has_earthstone = 0;
global.has_waterstone = 0;
global.has_firestone = 0;
global.has_dlstone = 0;

//COLLECTABLES//
global.hasheart1 = 0;
global.hasheart2 = 0;
global.hasheart3 = 0;
global.hasheart4 = 0;
global.hasheart5 = 0;
global.sm_key = 0;
global.bg_key = 0;
//SMALL KEY AVOID RE-APPEARING
global.sm_key_001 = 0;

//DOOR OPEN
global.door_21 = 0;


//INIT STATE VARIABLE//
enum states
{
    normal,
    ladder,
    attack,
    dash,
    hurt,
    trans,
    vdialog,
    vcrouch
}

enum u_item
{
    ui_nothing,
    ui_glowurm,
    ui_gloves,
    ui_bombs,
    ui_vortex
}
//CLOSE INI FILE//
//////////////////
ini_close();

//INITIALIZE WINDOW POS AND RES//
/////////////////////////////////
if global.fullscreen == false
{
    window_set_fullscreen(global.fullscreen);
}

window_set_size(1280,720);

//display_reset(0,true);

steam_initialised();

//AFTER TESTING WE WILL TURN AUDIO ON//
//audio_play_sound(bgm_main,0,0)

room_goto(rm_mainmenu);
 
T

tafkatfos

Guest
I just have it set as a toggle via key press.

Code:
/// Toggle vsync
if (vsync == false)
{
  display_reset(0, true);
  vsync = true;
  script_execute(SaveSettings);
}
else
{
  display_reset(0, false);
  vsync = false;
  script_execute(SaveSettings);
}
 
K

Kyle Rider

Guest
That is a solution I just don't think it seems professional. I just don't know how to load the game if the player doesn't want VSync on. I am guessing it is on by default.
 

Mick

Member
I just have it set as a toggle via key press.

Code:
/// Toggle vsync
if (vsync == false)
{
  display_reset(0, true);
  vsync = true;
  script_execute(SaveSettings);
}
else
{
  display_reset(0, false);
  vsync = false;
  script_execute(SaveSettings);
}
You can simplify your code (just to let you know):

Code:
// Toggle vsync
vsync = !vsync;
display_reset(0, vsync);
SaveSettings();
 
T

tafkatfos

Guest
That is a solution I just don't think it seems professional. I just don't know how to load the game if the player doesn't want VSync on. I am guessing it is on by default.
Use a settings ini file. For example my game loads a settings ini file (vsync off/on, audio on/off, fullscreen etc.) when it boots up via my objGame, so if it's off in the file then it's off and if the user has enabled it previously then it's automatically on when the game boots up.

Nothing unprofessional about it.
 
Last edited by a moderator:

GMWolf

aka fel666
Code:
//OPEN INI FILE//
/////////////////
ini_open("settings.ini");

//AUDIO//
/////////
global.ambientSound = ini_read_real("sound", "ambient", 50);
global.effectSound = ini_read_real("sound", "effect", 50);
global.musicSound = ini_read_real("sound", "music", 50);

//VISUAL//
global.fullscreen = ini_read_real("Fullscreen", "fscreen", true);
global.aasetting = ini_read_real("AntiAlias", "aasetting", 0);
global.vsyncsetting = ini_read_real("VSync", "vsyncsetting", true);


//INITIALIZE INPUT GLOBALS//
////////////////////////////

//DIRECTIONS//
//////////////
global.key_up = ini_read_real("controls", "up", keyboard_get_map(vk_up));
global.key_down = ini_read_real("controls", "down", keyboard_get_map(vk_down));
global.key_right = ini_read_real("controls", "right", keyboard_get_map(vk_right));
global.key_left = ini_read_real("controls", "left", keyboard_get_map(vk_left));


//BUTTONS//
///////////
global.key_jump = ini_read_real("controls", "jump", keyboard_get_map(ord ("W")));
global.key_item = ini_read_real("controls", "item", keyboard_get_map(ord ("S")));
global.key_attack = ini_read_real("controls", "attack", keyboard_get_map(ord ("D")));
global.key_special = ini_read_real("controls", "special", keyboard_get_map(ord ("A")));
global.key_gpause = ini_read_real("controls", "gpause", keyboard_get_map(ord ("E")));

//Player variables//
////////////////////
global.phpmax = ini_read_real("MaxHealth", "phpmax", 6);
global.php = ini_read_real("CurHealth", "php", 6);
global.dir = ini_read_real ("Direction", "dir", 1);
global.player_pos = ini_read_real("Position", "player_pos", 0.0);
global.px = ini_read_real("Player_X", "px", 128);
global.py = ini_read_real("Player_Y", "py", 832);
global.roomx = ini_read_real("Room X", "roomx",3);
global.roomy = ini_read_real("Room Y", "roomy",2);
global.u_item = ini_read_real("Item Icon","u_item", 0);
global.end_dialog = false;
global.compass = 0;
global.vstory = 0;
global.dimvar = 0.8;


//INVENTORY//
/////////////

//SKILLS//
global.has_dbljump = 0;
global.has_trpjump = 0;
global.has_charge = 0;
global.has_dash = 1;

//ITEMS//
global.has_glowurm = 0;
global.has_gloves = 0;
global.has_vortex = 0;
global.has_bomb = 0;

//STONES//
global.has_windstone = 0;
global.has_earthstone = 0;
global.has_waterstone = 0;
global.has_firestone = 0;
global.has_dlstone = 0;

//COLLECTABLES//
global.hasheart1 = 0;
global.hasheart2 = 0;
global.hasheart3 = 0;
global.hasheart4 = 0;
global.hasheart5 = 0;
global.sm_key = 0;
global.bg_key = 0;
//SMALL KEY AVOID RE-APPEARING
global.sm_key_001 = 0;

//DOOR OPEN
global.door_21 = 0;


//INIT STATE VARIABLE//
enum states
{
    normal,
    ladder,
    attack,
    dash,
    hurt,
    trans,
    vdialog,
    vcrouch
}

enum u_item
{
    ui_nothing,
    ui_glowurm,
    ui_gloves,
    ui_bombs,
    ui_vortex
}
//CLOSE INI FILE//
//////////////////
ini_close();

//INITIALIZE WINDOW POS AND RES//
/////////////////////////////////
if global.fullscreen == false
{
    window_set_fullscreen(global.fullscreen);
}

window_set_size(1280,720);

//display_reset(0,true);

steam_initialised();

//AFTER TESTING WE WILL TURN AUDIO ON//
//audio_play_sound(bgm_main,0,0)

room_goto(rm_mainmenu);
So does the game start tiny only if you uncomment the display reset line?
 
T

TimothyAllen

Guest
Try waiting a couple of steps (via an alarm) before resetting the display. Maybe there is some weird thing going on there during the boot up of the game.

EDIT: In my games, i always wait at least one step after my initialization room before I create my displayManager object.
 
K

Kyle Rider

Guest
I placed the display reset in my obj_game and it had an error due to my lighting, the surface I create is no longer existing.
I am sure I will figure this out! hahaha
 

GMWolf

aka fel666
I placed the display reset in my obj_game and it had an error due to my lighting, the surface I create is no longer existing.
I am sure I will figure this out! hahaha
May I recommend you use my surface manager asset? It should avoid these sorts of errors, and is entirely free :)
 
Top