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

Legacy GM Do some code require physical input to work?

M

MexicanBurrito

Guest
Hello everyone!

Yesterday I created a system to change the aspect ratio of my game when I click either 1,2,3, or 4 and it worked! It resized views acordingly and the application surface aswell. Today I wanted the game to do it automatically. I tried to get my boyfriend to help me but he was a clueless as I :(
Code:
if (display_get_height() / display_get_width() == 1.777777777777778)
{
    global.threebyfour = 0
    global.sixteenbynine = 1
    global.sixteenbyten = 0
    global.twentyonebynine = 0
}

else if (display_get_height() / display_get_width() == 1.6)
{
    global.threebyfour = 0
    global.sixteenbynine = 0
    global.sixteenbyten = 1
    global.twentyonebynine = 0
}

else if (display_get_height() / display_get_width() == 2.333333333333333)
{
    global.threebyfour = 0
    global.sixteenbynine = 0
    global.sixteenbyten = 0
    global.twentyonebynine = 1
}

else if (display_get_height() / display_get_width() == 1.333333333333333)
{
    global.threebyfour = 1
    global.sixteenbynine = 0
    global.sixteenbyten = 0
    global.twentyonebynine = 0
}
Its just to cover the normal aspect ratios and 21 / 9 just for fun :) then it stores the result in these global variables.

Code:
if (global.threebyfour = 1)
    {
        view_hview[0] = 270;
        view_wview[0] = 360;
        view_hport[0] = 270;
        view_wport[0] = 360;
        surface_resize(application_surface, 360, 270);
    }
else if (global.sixteenbynine = 1)
    {
        view_hview[0] = 270;
        view_wview[0] = 480;
        view_hport[0] = 270;
        view_wport[0] = 480;
        surface_resize(application_surface, 480, 270);
    }
else if (global.sixteenbyten = 1)
    {
        view_hview[0] = 300;
        view_wview[0] = 480;
        view_hport[0] = 300;
        view_wport[0] = 480;
        surface_resize(application_surface, 480, 300);
    }
else if (global.twentyonebynine = 1)
    {
        view_hview[0] = 270;
        view_wview[0] = 630;
        view_hport[0] = 270;
        view_wport[0] = 630;
        surface_resize(application_surface, 630, 270);
    }
Then it checks the global variables and resizes the game accordingly.

This all worked out fine when the first code part was inputed physically and now it doesn't. Maybe there is something wrong with the code :(

any help would be appreiceated.
 

jo-thijs

Member
You're doing this:
Code:
display_get_height() / display_get_width()
but it should be:
Code:
display_get_width() / display_get_height()
Also, don't check if it equals 1.777777777777778,
check if it equals 16 / 9 instead.

And also have a mechanism that deals with the situation when the display ratio isn't any of the given 4,
make it search for a best fit.
 
Top