• 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 [Solved] Resolution Issues

Papa Doge

Member
Hello,

The height of my game is being squished for an unknown reason.

I'm having trouble tracking down the root cause of my game's resolution issues. I've watched the videos by Pixelated Pope and that didn't fix my issue either. I'm wondering if there's still something fundamental I'm missing or if there's some random bit of code in my game that junking things up.

As you can see in the attached screenshot, it's the draw event's content that is messed up but for whatever reason the GUI layer seems to be drawing correctly.

Here are my settings:

Room
5152 x 3808

Viewport 0
Camera: 728 x 432
Viewport: 728 x 432

Then I use a camera object from Shaun Spaulding platformer tutorial series to center on the player and clamp the view when I do screen shakes.

Code:
// CREATE EVENT

/* -------------------- */

// Variable to identify the default camera so we can do things to it...
cam = view_camera[0];

// Variable to store the object we want the camera to be following...
follow = obj_player_suit;

// Variables to store half the width and height so that the camera can be positioned on the center of the subject...
half_camera_width = camera_get_view_width(cam) * 0.5;
half_camera_height = camera_get_view_height(cam) * 0.5;

// Variables to store where we want the camera to go with defaults at the camera objects starting location...
x_target = x;
y_target = y;

// camera shake

shake_length = 0; // 30 is half a real world second of shaking...
shake_magnitude = 0; // how much it will shake the camera in pixels...
shake = 0; // variable to store current remaining shake value...
shake_buffer = 32; // so you don't shake off the screen...

// STEP EVENT

// if the subject still exists...
if (instance_exists(follow)) {
    // grab the x and y coords of the subject and store them as variables...
    x_target = follow.x;
    y_target = follow.y;
}
 
// incrementally update the camera's position to follow the subject so it's fast when far away and slow when close...
x += (x_target - x) / 10;
y += (y_target - y) / 10;
 
// restrict the position of the camera so that it can't go outside the bounds viewport...
x = clamp(x,half_camera_width+shake_buffer,room_width-half_camera_width-shake_buffer);
y = clamp(y,half_camera_height+shake_buffer,room_height-half_camera_height-shake_buffer);

// camera shaking here...
x += random_range(-shake,shake);
y += random_range(-shake,shake);
shake = max(0,shake-((1/shake_length)*shake_magnitude)); // remove 1/60 of shake's value every frame so that in 60 frames (one real world second) the shake will end...
 
// update the camera so that it is centered on the player instead of being in the top left...
camera_set_view_pos(cam,x-half_camera_width,y-half_camera_height);
---

I pretty sure it's not the camera becuase I turned that object off and the game is still getting squished. Then I thought maybe my room being such a strange size might be the issue. So I made it 1920 x 1080 just to see if everything being the same aspect ratio would fix the issue. It did not.

From what I gather, the room size does not matter but the camera and viewport aspect ratios must be the same. So I could make the viewport 2x the camera to scale my game by 2x. This is my goal but as I said, I'm not sure why anything is getting squished when both my camera and my viewport are identical.

Could it be something with the application surface? Something else? I'm a bit stuck.
 

Attachments

Last edited:
R

robproctor83

Guest
Your showing us the code for centering the camera but the problem is related to your resolution. How are you resizing the application surface? That's likely where the problem is. Looking at the screenshot it looks like at the very bottom it's an empty gap. I'm thinking you are drawing the application surface incorrectly.
 

Papa Doge

Member
Yeah, OK. Application surface stuff...

Honestly I don't mess with it hardly at all, and maybe that's the problem? These are the only two functions I use in my code:

Code:
application_surface_draw_enable(); // I flip this from true to false and back again when applying shaders
draw_surface(application_surface, 0, 0); // For positioning the draw event in the top left
And nothing's getting cut off in that screenshot. It's trippy because of the black background right now (I"m redoing all my tile sets) but those boulders terminate flat into the ground.
 
R

robproctor83

Guest
That Boulder on the bottom center, it's bottom looks possibly cutoff or that could be just the art. Your sure that the application surface is stretching to the very bottom of the screen? And, are you not resizing the application surface?

What you should do is debug. Print out all relevant data and make sure it's right. Look at the view size, port size, camera size, application surface size.
 

Papa Doge

Member
Ah ha! Wow, why did I not think to just print this out. So silly, I'm sorry I didn't include this from the get go:

Code:
My room size is 5152 x 3808
My camera size is 2048 x 1024
My viewport size is 728 x 432
That's the debug message I get back. So somewhere, somehow, my camera is getting resized. Very interesting. I'll do some investigating and report back.
 

Papa Doge

Member
Found it.

The issue was in the room properties settings. I have a room that initializes a lot of things and then moves right on to the next room. That initialization screen had camera settings that were different from the first room.

So I guess when you move from room to room you have to manually resize things in code? That part is still a mystery to me but I have no reason for them to be different at the moment so I can put a pin in this and come back later.

Thanks for you help @robproctor83 !
 
Top