How to: Temporarily Change Resolution for a 900*1600 image background (Room)

Started by Spocker, Sun 19/03/2023 11:17:24

Previous topic - Next topic

Spocker

Hi there!

I'm a total beginner but I have a question that needs to be solve at the beginning of a game, so it's perfect.
For my Rooms, I use background images of 1600*900 and the same resolution in the General Settings. However, I have one image background that I use differently, not as a "paysage" but as a "portrait". It's 900*1600.

Is it possible via a script command (beginner here) to temporarily change the resolution of the screen (900*1600?), and set it back to normal (1600*900) after that?
Should I put this script in the "First Time enters room" Event?

How would you recommend that I try that?

Thank you for your help!

Snarky

Hi Spocker, and welcome to AGS.

No, the game resolution is fixed, but you can achieve various effects by changing the Viewport/Camera and the room resolutions. So the question is more how you want this screen to appear in game. For example, do you want it to scroll vertically? And since the width is smaller than the width of the other rooms, would you want the sides to be filled with black, or the background to be "zoomed in" so that it fills the whole width of the screen, or what?

Spocker

Hi there!

Thanks for answering. Ok, I see for the resolution, thanks!
Here is a picture to help see the issue.

I don't need it to scroll nor zoom: it's really like any other room. But this one is litterally a closet, in which the player is "hiding". So the img background has a different size and appears vertical (900*1600).

But I would like the image to vertically fit entirely in my screen (which it doesn't on the picture I sent) - without loosing too much quality ^^'
And if it could be centered, and the sides filled with black but impossible to check with the mouse, it would be great. I mention not being able to click on the black sides as they will obviously be filled with black, but it would have to appear like the screen limits just stopped at the image background limits.

Does that make any sense? ^^

Thanks again!

Snarky

Great, I see what you're trying to do.

With a game resolution of 1600x900, that is (basically) the maximal resolution you can display in-game. So if you want to fit all of a 900x1600 image on-screen, you will need to scale it down (in an image editing app) so that it fits, i.e. to 506x900. This necessarily means you will lose image quality. You can then pad it with black on the sides to fill the screen.

Spoiler
Now, there is an exception to this, in that it's possible to "render sprites at screen resolution," a setting affecting characters and objects. If you made your background an object, you could scale it down in-game to fit the screen, and depending on the player's screen resolution, it might show in the full resolution. However, the AGS in-game scaling is primitive, so this could also introduce even uglier artifacts, and it wouldn't work at all for people playing the game in a window without upscaling, or in traditional full-screen.

I would not recommend this solution.
[close]

The easiest way to make sure the mouse cursor doesn't move outside of the active parts of the image is to check the position against the borders in the room's repeatedly execute function. However, note that this can be a problem for people who play the game in windowed mode, since it can trap the cursor over the game window.

Spocker

Hi there!

Thank you for answering again, it was quick and efficient. I had to reread the last bit because it's my first time scripting, but it ended up like this:

Code: ags
function room_RepExec()
{
    if (mouse.x <= 480) {
      mouse.Visible = false;
    }
    else if (mouse.x >= 1101) {
      mouse.Visible = false;
    }
    else {
      mouse.Visible = true;
    }
}

I didn't know how to do : IF / OR / ELSE, I just found out how to say IF / ELSE IF / ELSE.
But it works!

Here goes the result, thanks again. I think we can close the topic!


Snarky

Nice work!

The way to do OR is to put it inside of the if-condition. The symbol "||" (two bars) means a logical OR, while "&&" (two ampersands) means a logical AND. So you could instead write:

Code: ags
function room_RepExec()
{
    if (mouse.x <= 480 || mouse.x >= 1101) {
      mouse.Visible = false;
    }
    else {
      mouse.Visible = true;
    }
}

Khris

You can also use an even shorter way:
Code: ags
  mouse.Visible = mouse.x > 480 && mouse.x < 1101;

However a much better way to solve this is to use  Mouse.SetBounds(); this way the user doesn't suddenly "lose" their mouse.

Crimson Wizard

Quote from: Khris on Mon 20/03/2023 17:41:12However a much better way to solve this is to use  Mouse.SetBounds(); this way the user doesn't suddenly "lose" their mouse.

I must mention that Mouse.SetBounds is implemented by forcing mouse position to stay within the rectangle, which makes player unable to move it outside the window too when they play in windowed mode.

Another thing to consider, is how the mouse can still interact with the GUI, if there's one in game at that scene.

Cassiebsg

I want to add, as a player, that I hate "losing control" of the mouse. I always play windowed, and if my mouse it locked to the game or a little box inside the game, I panic!
This means I will stop playing, do all I can to release the mouse again, and if I can't... I may just stop playing altogether.

What is wrong with the mouse cursor being over the black parts of the room? As long as nothing happens when you click there, I can't see the problem, really.
There are those who believe that life here began out there...

SMF spam blocked by CleanTalk