#Pretty scaling in 2D Pixel art game

1 messages · Page 1 of 1 (latest)

fast dagger
#

Hi there, I'm currently making a 2D Pixel art game.

Therefore, I configured my project like this:
Size:
Viewport width : 640
Viewport height : 360
Stretch:
Mode : viewport
Aspect : keep
Scale : 1
Scale mode : integer

Which is a blast.

The problem is : My screen doesn't fill up the whole window if it's size is not an integer factor of my base resolution.
Your answer will be : "It's not a bug, that's the feature you triggered yourself"

Yes. I want my scaling to be an integer but I also want my game to fill up the screen it's in. To do so I wanted to scale my game by the integer ROUNDED UP of the float that could fill my window. This way I lose the borders of my image but I can make a game larger than it's needed to in order to not lose anything important when I cut a part of the borders.

How to do that ? I tried to play with cameras, with the viewport properties etc, but I had no luck. What is the good way of solving this ?

jovial onyx
#

I don't know how to do exactly as you asked, but one way around this issue is to use a setting menu with set resolution options and then adjust the project scaling based on that option.

It could be something that's conceptually like this:


const RES_STR_TO_INTEGER_SCALE: Dictionary = {
"640×360":1,
"1280×720":2,
"1920×1080":3
}

func set_custom_project_scale(screen_resolution_str: String) -> int:

*insert project scale variable here* = RES_STR_TO_INTEGER_SCALE[screen_resolution_str]```

When you call that function or set the variable is up to you.

If no one can come up with a good answer, this seems like a legitimate option. There's also probably a better way of doing this using an enum.
steady hill
#

Think I found half of what you need :
small original view vs scaled up (grey bar is empty scene as opposed to letterbox)
Though idk if/how to keep it centered if you find that let me know!

fast dagger
#

My goal is for my game to fill the whole space

fast dagger
#

Thank you to both of you to give me some of your time

steady hill
fast dagger
hybrid jungle
#

I'm just going to mention subviewport in a subviewportcontainer as a wrapper around your scene, rendering at a fixed 360p, and then scaling the subviewportcontainer so that it always is covering the whole screen

steady hill
fast dagger
steady hill
#

Which sounds like void's idea with extra steps I think

hybrid jungle
#

fractional scaling would distort the viewport I think, and if I understand correctly you want to cut off the edges isntead right

fast dagger
hybrid jungle
#

yeah it would require some setup but be possible

fast dagger
steady hill
#

Thanks appreciate it I'll have to implement something similar eventually too

fast dagger
#

My only fear is that id could be impossible to a subviewport to be bigger than the actual viewport, I had this problem in the past

#

But the setup was completely different, I'll do my tests

hybrid jungle
#

I would say
SubviewportContainer with stretch disabled, size set to the pixelart resolution, then use its scale and position to make it occupy the window however you like
as a child Subviewport, again set to the pixelart resolution and all the settings you might want
as a child of that your active scene