G
Guest
Guest
I've read the manual for rooms, viewports, cameras, windows, displays, surfaces, the application surface, and the gui layer. I've watched Pixelated Pope's scaling tutorials. I read this thread that asked a very similar question but kind of devolved. So, I'm not lazy, just slow.
My game is a grid based game intended for mobile, think of it like a chessboard. The real size of the gameboard--the room--is 160 x 224.
The problem is that I need a GUI above and below the room. The best solution I've found is to set a larger viewport at my desired ratio, 16:9, which is 162 x 288. This gives me 64 unscaled vertical pixels to use for the GUI.
I set a y offset for the viewport of 32, centering the room. Then I wrote the following Draw GUI code to try to draw blue rectangles where the GUI should go, no matter how it's scaled, using "keep aspect ratio" in the main options:
This works well--mostly. At all the common resolutions, it looks like this:
But I can make it bug out if I drag the corner into odd positions; worse, it does this at 340x640, which I read is the "viewport" (not resolution) of the Galaxy S7. (And please let me know if a phone's "viewport" doesn't matter versus its resolution, because then I can just ignore this problem.)
The bad result, like at 340x640, looks like this, where lime green is my room background color:
And I absolutely cannot figure out why it does this. Any pointers would be very welcome.
(I've tried using multiple viewports, setting the GUI size to the desired viewport size and drawing the application surface in the GUI draw event, but none of this has given any better results. I need to draw over the extra space because my game uses wrapping, and GM draws objects outside of the room.)
My game is a grid based game intended for mobile, think of it like a chessboard. The real size of the gameboard--the room--is 160 x 224.
The problem is that I need a GUI above and below the room. The best solution I've found is to set a larger viewport at my desired ratio, 16:9, which is 162 x 288. This gives me 64 unscaled vertical pixels to use for the GUI.
I set a y offset for the viewport of 32, centering the room. Then I wrote the following Draw GUI code to try to draw blue rectangles where the GUI should go, no matter how it's scaled, using "keep aspect ratio" in the main options:
Code:
var dw = window_get_width();
var dh = window_get_height();
var dm = dh / view_get_hport(0); // calculate how much we've scaled up (display multiplier)
// top bar
draw_rectangle_color(0, 0, // origin is the top-left corner
(view_get_wport(0) * dm), // bottom-right x equals the width of the viewport, scaled up to the display
(((dh - (room_height * dm)) / 2)), // bottom-right y is half the extra space(display_h minus scaled room_h)
c_navy, c_navy, c_navy, c_navy, false); // navy-colored and opaque
// bottom bar
draw_rectangle_color(0, // origin x
dh - (((dh - (room_height * dm)) / 2)), // origin y is half the extra space up from the bottom
(view_get_wport(0) * dm), // bottom-right x equals the width of the viewport, scaled up to the display
dh, // bottom-rght // bottom-right y equals the bottom of the display
c_navy, c_navy, c_navy, c_navy, false); // navy-colored and opaque
But I can make it bug out if I drag the corner into odd positions; worse, it does this at 340x640, which I read is the "viewport" (not resolution) of the Galaxy S7. (And please let me know if a phone's "viewport" doesn't matter versus its resolution, because then I can just ignore this problem.)
The bad result, like at 340x640, looks like this, where lime green is my room background color:
And I absolutely cannot figure out why it does this. Any pointers would be very welcome.
(I've tried using multiple viewports, setting the GUI size to the desired viewport size and drawing the application surface in the GUI draw event, but none of this has given any better results. I need to draw over the extra space because my game uses wrapping, and GM draws objects outside of the room.)
Last edited by a moderator: