YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
21 stars 8 forks source link

In-Game: [GX.Games] window_set_size() has no effect on local runs from the IDE #1752

Open gm-bug-reporter[bot] opened 11 months ago

gm-bug-reporter[bot] commented 11 months ago

Description

HTML5 and Windows will respect Game/Window size, and calling window_set_size will update it. GX.Games ignores this completely, and will always display the game occupying the whole window.

This is not desirable for testing Pixel Art Games, as non-integer scaling produces not ideal results.

This seems like a bug because the functionality is present on the runner.html onGameSetWindowSize(width,height) exists, but ensureAspectRatio() ignores the width and height, and instead uses: window.innerWidth;

Steps To Reproduce

1) Create a new project 2) Ensure Game Options is set to "Keep aspect ratio" for GX.games 3) Use window_set_size() 4) Notice: HTML5 and Windows respect this, but GX.Games will always fill the whole browser screen.

b95de75a-1e5a-4ad6-82ce-a610990c3aba

ShivaSouza commented 11 months ago

forgot to add that this happens with keep aspect ratio turned on

Here is my amateurish solution, On runner.html I edit these codes:

function onGameSetWindowSize(width,height)
    {
    startingHeight = height;
    startingWidth = width;
        startingAspect = startingWidth / startingHeight;

    //calls the function to resize the game Canvas.
    ensureAspectRatio(); //<---- - -
  }

function ensureAspectRatio() {     
    (...)
    if (heightQuotient > widthQuotient) {
        // Max out on height, respecting the Height defined by the player.
        newHeight = Math.min(maxHeight, startingHeight); // <---- - -
        newWidth = newHeight * startingAspect;
    } else {
        // Max out on width, respecting the Width defined by the player.
        newWidth = Math.min(maxWidth, startingWidth);  // <---- - -
        newHeight = newWidth / startingAspect;
    }
    (...)
}
andrewcirel commented 2 months ago

Agreed, window_set_size isn't working in gx.games which makes this export unusable. The real question is why bugs like this are not resolved 9 months later?