GameMaker [SOLVED] Another impossible scalling case

N

Naoki

Guest
Hello everyone,

I am desperately seeking help to scale my game, I just can't understand this stuff, nothing is working, I constantly have weird results.

I developped a Shoot' em up using 1920*1080 rooms. My computer screen is also 1920*1080. Now I want to scale it to whatever screen the player is using. At this point, I don't care if they have black bars, I just want to be done with this nightmare.
I tried RangerX tutorial but for some unknown reasons it's just not working. Right now I am trying to make it work with a 1366*768 resolution, so I had this code (I asked for help on reddit so I changed a bit the code from the tutorial):

Code:
application_surface_draw_enable(false);
window_set_fullscreen(true);
global.MonitorW=display_get_width();
global.MonitorH=display_get_height();

if (global.MonitorW>=1366 && global.MonitorH>=768){
global.view_width = 1366;
aspect_ratio = global.MonitorW / global.MonitorH
global.view_height = global.view_width / aspect_ratio
display_set_gui_size(global.view_width, global.view_height);
surface_resize(application_surface,global.view_width,global.view_height)
global.Xoffset=(global.MonitorW-1366)/2;
global.Yoffset=(global.MonitorH-768)/2;
}

This code is in a specific object alone in a room set at the very beginning of the game.
It's not working for various reasons. First, the collision boxes are not on the sprites anymore. For example, when I am on the main menu I have individual buttons like "Play", "Options" etc. I am supposed to click on them to activate them. It works fine in 1920*1080 but when I scale the game, I have to actually click next to the button a little bit below to click on their collision box.

Now I am completely lost, I don't know what I should do. Am I supposed to change the room size? Change the view or viewport size?
When I test, my GUI is 1366*768, same for my application surface, I tried to change the view, viewport and room size but it's solving nothing, it's just adding new problems like text overlapping on each other.

I thought too much about it, everything is blurry in my mind now. :(
 

NightFrost

Member
Well, you are changing your app surface and GUI size there, and assumedly view too since you prepare its dimensions into globals. I assume you're still using the same font everywhere though, so when your dimensions are smaller, less text fits on screen. This doesn't cause text overlap though, so you're probably calculating their positions as percentages of screen size? Smaller vertical size would mean less distance, pulling the menu options closer together. I can only guess again but the displacement of their click areas comes from them still being calculated from your originally used resolution, so they are no longer aligning with new draw positions.
 
N

Naoki

Guest
Oh I should have indicated that the buttons on the menu are images, not text.
To create them, I use in a oGlobalMenul object:
Code:
 instance_create_depth(room_width/2,480,-1,oMenuPlay)
And they all have a draw event with for example:
Code:
 draw_sprite_ext(sprite_index,-1,x,y,1,1,0,c_white,image_alpha)
So indeed, it looks like the object (and collision mask) is created depending on the room size and their sprite is drawn depending on the application surface. But, the problem is that if I change the room width and height, this collision box problem is still here. Even if the application surface and room sizes are the same, their collision box is not on the sprite, it's next to it. That's why I am really confused.
 
N

Naoki

Guest
Maybe you can understand better the problem with screenshots.
Here is the game in 1920*1080. Everything is fine, no problem at all:


And here is the game in 1366*768:

Do you see the red cursor next to "How to play"? This is where I have to click to activate the "Play" button.

And here is what I have when I have the same conditions than second screenshot but with a room that is 1366*768:

Collision box still broken here.
 

jo-thijs

Member
Hello everyone,

I am desperately seeking help to scale my game, I just can't understand this stuff, nothing is working, I constantly have weird results.

I developped a Shoot' em up using 1920*1080 rooms. My computer screen is also 1920*1080. Now I want to scale it to whatever screen the player is using. At this point, I don't care if they have black bars, I just want to be done with this nightmare.
I tried RangerX tutorial but for some unknown reasons it's just not working. Right now I am trying to make it work with a 1366*768 resolution, so I had this code (I asked for help on reddit so I changed a bit the code from the tutorial):

Code:
application_surface_draw_enable(false);
window_set_fullscreen(true);
global.MonitorW=display_get_width();
global.MonitorH=display_get_height();

if (global.MonitorW>=1366 && global.MonitorH>=768){
global.view_width = 1366;
aspect_ratio = global.MonitorW / global.MonitorH
global.view_height = global.view_width / aspect_ratio
display_set_gui_size(global.view_width, global.view_height);
surface_resize(application_surface,global.view_width,global.view_height)
global.Xoffset=(global.MonitorW-1366)/2;
global.Yoffset=(global.MonitorH-768)/2;
}

This code is in a specific object alone in a room set at the very beginning of the game.
It's not working for various reasons. First, the collision boxes are not on the sprites anymore. For example, when I am on the main menu I have individual buttons like "Play", "Options" etc. I am supposed to click on them to activate them. It works fine in 1920*1080 but when I scale the game, I have to actually click next to the button a little bit below to click on their collision box.

Now I am completely lost, I don't know what I should do. Am I supposed to change the room size? Change the view or viewport size?
When I test, my GUI is 1366*768, same for my application surface, I tried to change the view, viewport and room size but it's solving nothing, it's just adding new problems like text overlapping on each other.

I thought too much about it, everything is blurry in my mind now. :(
Hi and welcome to the GMC!

You're drawing things at different coordinates, but mouse_x and mouse_y still use the old coordinates, which don't match up anymore with where you draw things.

There are multiple solutions.

I think the best solution for you might be not to bother with RangeX's tutorial.
I don't see why the default GameMaker settings wouldn't do the job for you.
If you feel like it, you may rescale the application surface, but I wouldn't disable the automatic dawing of it.
 
N

Naoki

Guest
Hi and welcome to the GMC!

You're drawing things at different coordinates, but mouse_x and mouse_y still use the old coordinates, which don't match up anymore with where you draw things.

There are multiple solutions.

I think the best solution for you might be not to bother with RangeX's tutorial.
I don't see why the default GameMaker settings wouldn't do the job for you.
If you feel like it, you may rescale the application surface, but I wouldn't disable the automatic dawing of it.
Duuuude, it's working (almost) perfectly :eek: :eek: :eek:
Thanks so much.

So to explain what I have now, I still have the object in a specific room as explained in the tutorial with this code in the create event:

Code:
global.MonitorW=display_get_width();
global.MonitorH=display_get_height();

global.view_width = global.MonitorW
aspect_ratio = global.MonitorW / global.MonitorH
global.view_height = global.view_width / aspect_ratio

global.Xoffset=(global.MonitorW-global.view_width)/2;
global.Yoffset=(global.MonitorH-global.view_height)/2;
Considering it's working fine this way, I don't want to touch anything.

There is just one problem remaining: When I pause the game, I have this system where the game deactivate everything and just draw a screenshot. But when I am in 1366*768, it looks like this:

Just ignore the numbers on the left.
As you can see, the screenshot is not on all the screen. I checked on my computer and it's indeed 1366*768, it looks like the game is automatically resizing it. Is there any way to prevent this to happen?

Anyway, thanks so much for your help, you saved me from big troubles.
 

jo-thijs

Member
Duuuude, it's working (almost) perfectly :eek: :eek: :eek:
Thanks so much.

So to explain what I have now, I still have the object in a specific room as explained in the tutorial with this code in the create event:

Code:
global.MonitorW=display_get_width();
global.MonitorH=display_get_height();

global.view_width = global.MonitorW
aspect_ratio = global.MonitorW / global.MonitorH
global.view_height = global.view_width / aspect_ratio

global.Xoffset=(global.MonitorW-global.view_width)/2;
global.Yoffset=(global.MonitorH-global.view_height)/2;
Considering it's working fine this way, I don't want to touch anything.

There is just one problem remaining: When I pause the game, I have this system where the game deactivate everything and just draw a screenshot. But when I am in 1366*768, it looks like this:

Just ignore the numbers on the left.
As you can see, the screenshot is not on all the screen. I checked on my computer and it's indeed 1366*768, it looks like the game is automatically resizing it. Is there any way to prevent this to happen?

Anyway, thanks so much for your help, you saved me from big troubles.
Don't take a screenshot, but use surfaces instead (and convert them to sprites if you want them to be maintained when the game minimizes).
Copy the application_suface to another surace when you pause.
Then reset copy that surface back to the application_surface at the start of the draw event (begin draw event for example).
 
Top