Scaling, Resolution, and Aspect Ratio Management for GMS1 & GMS2

@Pineapple I don't really understand why you are drawing the app surface that way instead of just drawing it with a calculated scale, here's how I would do it:

console create:
ideal_width = 320;
ideal_height = 180;

window_set_size(1200,300); //or whatever
console step
scale = floor(min(window_get_width()/ideal_width,window_get_height()/ideal_height))
console post-draw
var _xoff = window_get_width()/2 - (ideal_width*scale/2);
var _yoff = window_get_height()/2 - (ideal_height*scale/2);


as for the mouse position detection thing, that's a bit of a pain. But it is possible to convert the window mouse coordinates to be relative to the room. Keep in mind, however, that this code does not take into account a moving camera. And if you start using the GUI layer for your UI, well things will just get even more complicated.

console begin step
var _win_w = window_get_width();
var _win_h = window_get_height();
var _ideal_w = console.ideal_width;
var _ideal_h = console.ideal_height;
var _game_w = _ideal_w*scale;
var _game_h = _ideal_h*scale;

var _xmarg = (_game_w-_win_w)/(scale*2);
var _ymarg = (_game_h-_win_h)/(scale*2); = lerp(_xmarg,_ideal_w-_xmarg,window_mouse_get_x()/_win_w); = lerp(_ymarg,_ideal_h-_ymarg,window_mouse_get_y()/_win_h); and are your new "mouse_x" and "mouse_y" Which means you can no longer use the built in mouse events. So I added this step event to obj_square
And the result:
Thanks for your reply.

I'm drawing the app surface this way because I want the sprite and particle effects to be applied on the full canvas and not on the 320x180 canvas, it looks a lot better on a bigger canvas.

Thanks for the solution! I'm sad there's not an easier solution, I guess I need to change all mouse events for my >50 objects if I want to implement this feature.

I'm just very surprised that there is no function to change the position or aspect of the application surface; you can change the place where it's drawn, but it's not actually there. If this was possible we didn't need this workaround. Maybe I'll one day send yoyo a feature request.
Last edited: