# GMS 2Getting the Ratio Right

#### KyleRansford

##### Member
I'm trying to find a resolution that is in between 320x180 and 640x360. That can scale to 1280x720p and 1920x1080p.

For the type of game I'm making the 320x180 is too "close" or "zoomed in" and the 640x360 is too "far."

For the time being I found that 426x240 actually looks like it work, but 426 doesn't evenly scale to 720p.

As 426 x 3 = 1278‬. and 240 x 3 = 720.

Also, since 1280 / 3 = 426.6666666666667 there is an uneven number.

By playing my game with the 426x240 resolution doesn't seem to cause any errors, except a slight pixel distortion.

My Camera object has a rounding function for how it moves. Maybe that's why it doesn't look like there's hardly any distortion?

#### Catastrophe

##### Member
You're looking for a 16:9 aspect ratio, so you want something that's 16x,9x
x = 20 -> 320x180
x = 40 -> 640x360
x = 80 ->1280x720
x = 120 -> 1920x1080

So you probably want x = 30: 480x270 the closest to the one you tried is x = 27->432x243 I believe

It probably looks like there's virtually no distortion just because it's close enough, or perhaps there's a pixel thin black bar border you're not seeing.

Last edited:

#### KyleRansford

##### Member
You're looking for a 16:9 aspect ratio, so you want something that's 16x,9x
x = 20 -> 320x180
x = 40 -> 640x360
x = 80 ->1280x720
x = 120 -> 1920x1080

So you probably want x = 30: 480x270 the closest to the one you tried is x = 27->432x243 I believe

It probably looks like there's virtually no distortion just because it's close enough, or perhaps there's a pixel thin black bar border you're not seeing.
Thanks for the resolutions! But oddly enough, I tried the 480x270, 432x243 resolutions and there's visible "jittering" in the Camera.

Also, you're right about the pixel thin black bar. But it only appears sometimes. Would code that rounds the x and y position of the Camera object have anything to do with how the pixels are displayed?

Edit: Visible jittering does occur with the 426x240 resolution when I play the game in full screen, but not in the windowed size. And distorted jittering when played full screen with the 480x270, 432x243 resolutions

This is code I have in the Create event of the Camera Object

Code:
``````target_ = o_player;

width_ = camera_get_view_width(view_camera);
height_ = camera_get_view_height(view_camera);
scale_ = view_wport / width_;``````
this is the code I have in the End Step event of the Camera Object
Code:
``````if !instance_exists(target_) exit;
x = lerp(x, target_.x, 0.1)
y = lerp(y, target_.y, 0.1)
x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);
x = clamp(x, width_/2, room_width-width_/2);
y = clamp(y, height_/2, room_height-height_/2);
camera_set_view_pos(view_camera, x-width_/2, y-height_/2);``````
The round_n is a custom script with
Code:
``````///arg value
///arg increment

var _value = argument0;
var _increment = argument1;
return round(_value/_increment) * _increment;``````

Last edited:

#### Catastrophe

##### Member
Possibly. I don't have any visuals to understand what's going on, so I would try three tests:

1)

if !instance_exists(target_) exit;
if (point_distance(x,y,target_.x,target.y < someAmountYouChoose)) {
x = target_.x
y = target_.y
} else {
x = lerp(x, target_.x, 0.1)
y = lerp(y, target_.y, 0.1)
x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);
}

2)

x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);

->

//x = round_n(x, 1/scale_);
//y = round_n(y, 1/scale_);

3)

x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);

->
(with obvious implementation)
x = floor_n(x, 1/scale_);
y = floor_n(y, 1/scale_);

#### KyleRansford

##### Member
Possibly. I don't have any visuals to understand what's going on, so I would try three tests:

1)

if !instance_exists(target_) exit;
if (point_distance(x,y,target_.x,target.y < someAmountYouChoose)) {
x = target_.x
y = target_.y
} else {
x = lerp(x, target_.x, 0.1)
y = lerp(y, target_.y, 0.1)
x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);
}

2)

x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);

->

//x = round_n(x, 1/scale_);
//y = round_n(y, 1/scale_);

3)

x = round_n(x, 1/scale_);
y = round_n(y, 1/scale_);

->
(with obvious implementation)
x = floor_n(x, 1/scale_);
y = floor_n(y, 1/scale_);
Thanks again. floor doesn't seem to help it much.

But also, I wonder why 480x270 makes it look visibly distorted (when scaled at 1080p) and 426x240 looks better?

When

480 x 4 = 1920
270 x 4 = 1080

and

426 x 4 = 1704
240 x 4 = 960

#### Catastrophe

##### Member
Honestly, I need a project file or a gif at this point, since a lot of what you're saying is kinda subjective (jittering/distorted). Something other than the aspect ratio being better sounds odd.