• 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 Make view(port) always the same as window size

0biwan

Member
Hello Community

I'm currently developing a "sim city" 2D city-builder style game and I am trying to build a realiable and flexible base for the main features and functions. Of course s very important part is the resolution, (GUI) scaling and size management. The game is mainly developed for Windows.

The idea is to let the user change his favourite resolution within an options menu and toggle fullscreen on and off. Because it's a city-builder, it doesn't matter how much of the room the user can see, therefore the view should always be the same as the resolution/window size (i.e. if the player has a higher resolution, he sees more of the room, if he has widescreen, he sees more to the left and the right, etc.)

Until now I set the viewport in the room preferences to 1920x1080 and I have a camera object creating a view that manages the camera (zoom and pan), all working fine.

Now I created a second room for my options menu with a few simple buttons (example code below) that change the window size to a fixed value. And now here is the problem: Resizing the window size works perfectly, but it always streches the screen content to the new resolution, meaning it always uses the 1080p viewport set in the room properties. I tried to change this with several attempts with none of them working correctly:

Code:
var new_width  = 1600;
var new_height = 1200;

window_set_size(new_width, new_height);

camera_set_view_size(view_camera[0],new_width, new_height);

view_set_wport(0, new_width);
view_set_hport(0, new_height);

surface_resize(application_surface, new_width, new_height);

view_wport[0] = new_width;
view_hport[0] = new_height;
What would you recommend on how to arrange this? Maybe my approach is wrong or there is a simpler solution for this kind of problem.

After this, the GUI scaling will be my next issue, since I have to do some testing on how this will best work with different aspect ratios and resolutions.

Many thanks for your help - any suggestions are appreciated!

Regards, 0biwan
 

RangerX

Member
Your game resolution is the view size.
So if you want more room space to appear on screen, you need to enlarge the view size. Make sure the viewport and application surface size is always following.
 
Top