GML Help With Scaling

B

BloodCorn

Guest
Hey!
My game is nearing release and there is one thing that I need to do but unfortunately, I have no clue where to start for it. My game is mainly based on draw_text() and some images and sprites, if anybody could give me any tips to scale for different display sizes it would be much appreciated.

Thanks,
BloodCorn
 
A

Adventure Byte

Guest
You should check out Pixelated Pope's tutorials on Youtube.

Search "Pixelated Pope Resolution Control" and watch the three part series, it is a great place to start!
 
B

BloodCorn

Guest
Unfortunately, my game does not have moving characters at all so this solution will not work for me, do you have any other ideas?
 
W

Wraithious

Guest
Check out this thread, there are tons of others on here too, it doesnt matter if you do or dont have moving objects, the goal is to scale your game or view to fit any device, and so you should consider first off what target you're releasig to and make your room size and/or view the most common resolution for that target to start with, then follow the advice on that thread or elsewhere, and @Pixelated_Pope 's videos definatly would do what you want also, like I said moving objects have nothing to do with you scaling your game to fit on a screen.
 
B

BloodCorn

Guest
Hi,
I have tried all of these options and it still just messes everything up when I use it.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
First, trying to adapt an almost finished game (you say you are nearing release) to scale AFTER having designed the game is a very bad idea, as you will have already coded position and stuff, meaning you will probably have to go back and re-do everything to suit the scaling method you choose. You really should have built your game with the scaling right from the start! When I'm making a game, I always start with the scaling and resolution before doing anything else as it has knock on effects for everything else...

Second, just saying it's "messing everything up" is of no use at all to anyone. We can't help you if you don't tell us what's being messed up and what exactly you want to do. It would also help if you showed some of the implimentations that you've done of all of the methods outlined in the linked topics (seriously, you've tried ALL of them???), as maybe we can spot what you've done wrong and help you fix it. What we can't do however is post a "one code fits all" formula for you to copy paste into your game and "just work".

So, a bit of info and some screenshots from you of what you have, what you want, and what's not working would go a long way to letting us help you...

;)
 
B

BloodCorn

Guest
Ok - I have got a pretty good system for resizing the text by changing the gui size, is there a good way to resize the sprites to scale down or up to the size?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
is there a good way to resize the sprites to scale down or up to the size?
So, a bit of info and some screenshots from you of what you have, what you want, and what's not working would go a long way to letting us help you...
There are loads of ways to resize the sprites. Set the image x/yscale, draw them to a surface and use draw_surface_stretched, create a new viewport and draw them in that... However we have ZERO information, so anything we suggest is just a shot in the dark. We can't help you unless you help us. ;)
 
W

Wraithious

Guest
Ok, I have made it work with the sprites but the problem is that the text is all blurry unless it is at its native resolution.https://gyazo.com/8ffc2d386aee6e3c0b27f51de6eed699
That looks like an aspect ratio error to me, Here is a helpful aspect ratio calculator, so first figure out what the most common aspect ratio for the platform(s) you are releasing your game to, then use the calculator and enter a number for either the width or height that you are aiming for, if the results have a decimal point keep decreasing the value you entered by 1 until the results give you 2 numbers with no decimal places. Use that as your game room or view's aspect ratio. if you are releasing to multiple targets repeat the above if there is a different 'most common' aspect ratio for those targets. when done check in game start what operating system is being used and (typically) in your game's first room's creation code set up your aspect ratio, and with the sprites and if you have backgrounds use the correct sprite sets and background images according to what operating system was detected, either that or to make the final game smaller just release 2 (or more) versions of the same game for each target os that requires a different aspect ratio.
Note on mobile, if you detected android for example, note that some of the new android phones now use the ridiculous 19:1 and 19.5 to 1 aspect ratio so if you want to support that you'd have to do an additional check using the display_get_width/height functions as well as checking the os.
 
Last edited by a moderator:
B

BloodCorn

Guest
Sorry, could you please explain to me where I use the aspect ratio calculator? If my resolution is 1920x1080 wouldn't that just mean to make it 16:9?

Thanks for your help,
BloodCorn
 
B

BloodCorn

Guest
ezgif.com-video-to-gif.gif @Wraithious Ok - I have got very close there is just one issue, when I change the resolution of the game an object glitches out and draws twice, the x and y for the object are still set correctly just the actual object has moved - very strange, any ideas?
 
W

Wraithious

Guest
Sorry, could you please explain to me where I use the aspect ratio calculator? If my resolution is 1920x1080 wouldn't that just mean to make it 16:9?

Thanks for your help,
BloodCorn
You just use the calculator online for reference, as you can see from this screenshot 1920x1080 is 16 by 9 resolution, so that's fine.
asp1.png
So what you want to do is go into the room properties and set your room size to 1920 X1080 and make your background 1920 x 1080
asp2.png asp4.png
(or scale it up to that size in code) (or set the view to a smaller size but still 16 by 9 resolution)
@Wraithious Ok - I have got very close there is just one issue, when I change the resolution of the game an object glitches out and draws twice, the x and y for the object are still set correctly just the actual object has moved - very strange, any ideas?
This could be caused by the background image being smaller than the room with the Tile: Horizontal and Tile: Vertical boxes checked in the background image properties, if you don't want to resize your room or background and uncheck those options that might fix that
upload_2017-9-29_8-7-18.png
But I'm guessing if you do the steps I listed under your first quote you shouldn't have to worry about that.
If that is not the case then you have a problem with your draw code, maybe you're telling it to draw the sprite twice? without seeing the draw code that is just a total guess but if you have a for loop drawing that image depending on how many of them you want to draw and at what positions then maybe some code is telling it to draw twice when you think it's telling it to draw once?
 
Last edited by a moderator:
B

BloodCorn

Guest
The problem is that the object seems to have two different x and y variables in the draw gui and step event. I don't know why but it is really frustrating! Any Ideas?
 

RangerX

Member
Of course they do.
The game itself is on the application surface. Pre draw, draw, post draw events are to draw on it.
On top of the application surface is the GUI layer, a totally independant plane. And this one is according the screen itself, not the room like objects.

Also, when you resize the application surface or pass from fullscreen to windowed, you might need to resize the GUI layer. That thing is a bit of a pain if you ask me. I personally ignore it entirely.
 
B

BloodCorn

Guest
Ok - The only problem I have now is a button which works at the default size doesn't work when it is expanded - this is my code:
if(point_in_rectangle(window_mouse_get_x(),window_mouse_get_y(),x-1.5,y-1.5,x+1.5,y+1.5) and !active and !active_timer) {
active = true;
}

Do you have any idea as to why this doesn't work when the gui layer is expanded? FYI this code is in the Draw GUI event.
 
B

BloodCorn

Guest
It was originally in the step event but the same thing happens.
 

RangerX

Member
Am not familiar with mouse control though. There's a couple of functions to get the mouse position and not just this one you're using. I guess you have to do it differently.
But It will need another person to give you a great answer. Am not knowledgeable enough with mouse
 
B

BloodCorn

Guest
Ok - I have fixed it just one teeny tiny issue to go - to handle the hovering I use the code:
if(point_in_rectangle(device_mouse_x_to_gui(0),device_mouse_y_to_gui(0),city_x-1.5,city_y-1.5,city_x+1.5,city_y+1.5) and !active and !active_timer) {
active = true;
}
if(active and !point_in_rectangle(device_mouse_x_to_gui(0),device_mouse_y_to_gui(0),city_x,city_y,city_x+750,city_y+750) or city_purchased) {
active = false;
city_purchased = false;
}

the first if statement works perfectly when scaling or not but the second one does not - it works when not scaling but not when it is, it just becomes inactive as soon as I move the mouse off the original point. I feel like this could be fixed really easily but I just don't know what to do.

Thanks
 
B

BloodCorn

Guest
Ok, I am now completely finished with scaling! Thank you so much for your help! :)
 
Top