• 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 Reselution problems

Y

Yoflaines

Guest
Hi I'm currently making a top down game and I have a object that rescales the room to your display without any issues but when i restart the room it doesn't work anymore. It is placed in the create event but I've placed in a step event and it still doesn't work but here is the codes

Code:
/// Sets the display

var D_width = display_get_width()
var D_height = display_get_height()

surface_resize(application_surface,D_width,D_height)

room_set_view(room2,0,true,0,0,D_width,D_height,0,0,D_width,D_height,0,0,0,0,obj_player)
room_set_view_enabled(room2,true)
my game is made in 640x360 resolution. I hope this is enough information but ask me if there is something i need to add.
 

Tthecreator

Your Creator!
Well you probably also have to resize your window using:
Code:
window_set_size(D_width,D_height)
Maybe that will help
 
Y

Yoflaines

Guest
Nope that doesn't work, its still happening, the problem is when i restart the room it goes in to my screens reselution 1920x1080
 

Jakylgamer

Member
make an initialization room (just a blank room) and place your resize code in there

room creation code:
Code:
var D_width = display_get_width()
var D_height = display_get_height()

surface_resize(application_surface,D_width,D_height)

room_set_view(room2,0,true,0,0,D_width,D_height,0,0,D_width,D_height,0,0,0,0,obj_player)
room_set_view_enabled(room2,true)
room_goto(room2);
and everytime you need to restart just go to that room
 

RangerX

Member
Your room should be a fixed size and its the view that you should resize. And if you're not using views well... use them!
They are there to avoid you problems like this one and and multitude of others you did not encounter yet. ;)
 

DukeSoft

Member
A few things to note;

- Don't use surface_resize in a step event. Its a pretty intensive function and will slow down your game a lot - you should only have to use it once the settings change.
- room_set_view changes it for the room "object", not the current instance.
- You shouldn't change the room size based on the resolution settings. Your room is basically the definition of the level - resizing the room will create space on the right and bottom side while the level itself will stick to the left top side. It would look weird.

Short answer: The way to fix your code is to use the *current*, *active* room settings. The room_set_view will change the properties of the room, not the current "loaded" settings of the room. You can use those functions to change properties of a room, before going in to it.

If you want to change the current room settings, you should change the variables room_width, room_height and view_*.

Still, its bad practice to change the room size. You should use views, and adapt that based on the resolution settings.

If the game is dependant on a specific view size (e.g., you shouldn't be able to look wider than the view), you should not change the view size. You can change the surface size, and scaled down sprites / backgrounds will be scaled up to fit the view (so if you have a 0.5 scaled sprite on 1280x720, it will look like 0.75 on 1920x1080 - so it won't be pixelly but it will actually look good).

The way I do it, is that I store the "resolution" settings in an INI. On game start, the settings load, and everything is ran like the code above. If someone changes the settings in a settings menu, you re-run the "setupDisplay" script again.

Now, to fix your specific problem the hard way:
1) Enable views in the room. Setup the view exactly as you'd want the game to be. I'm guessing your room is 640x360 and you're always showing the entire room on the screen - even now you should enable the use of a view.
2) Make a script, call it something like "setupResolution"
3) In this script, use the following functions;
Code:
surface_resize(); //To resize the surface that the game is rendered on
window_fullscreen(); //To set the game fullscreen or not, based on the preference
window_set_size(); // To set the window size (maybe someone wants  640x360 windowed, or maybe 1280x720 windowed?
texture_set_interpolation(); //If you're doing a pixel-art ish game, don't use interpolation
To keep it simple, in this specific case, I would go with just the window_set_size() function, to resize the window. In a drawing event of a controller object (a persistant object thats always ONCE in your game) you call the following functions:
CREATE:
Code:
application_surface_enable(false); //Dont make the game draw the application surface automatically
DRAW GUI END:
Code:
draw_surface_stretched(application_surface, 0, 0, display_get_gui_width(), display_get_gui_height()); //This draws the application surface over the entire GUI - the maximum size of the window
With the latter code you can resize the window all you want, but the game will keep being drawn into the entire window. Please take care that if you use another scale than 16:9 (640x360, 1280x720, 1920x1080) it will stretch.
 
Top