Game
Hensen Hopper
23 days ago

Guess who's home from work! I want to explain in more detail the challenge the backdrop idea posed, how I initially had solved it and how I'm solving it NOW.


As I mentioned in my previous post, my initial idea was to take the backdrop script I had initially written to allow me to change the UI backdrop image in the main menu and make it an abstract class that I could write derivatives of for UI image and sprite-based backdrops, and I DID do this.

The only problem, though, was that it was possible for empty space in the scene beyond the backdrop to be visible if the player used an ultra-wide monitor with an aspect ratio greater than 16/9. Perhaps this issue can be better described by demonstration, in the screenshot below, I scaled up the game-view window in the Unity editor to an ultra-wide aspect ratio to show what the result was when I hit "play" (please excuse the unfinished backdrop image)

unity_pqyvngf0ul.png

As you can see, there is empty space outside of the backdrop visible on the screen which not only breaks the immersion but is plainly and simply ugly to look at.

My idea for how to confront this originally was for the sprite-backdrop script to re-scale the backdrop sprite renderer according to the width of the users screen relative to the height. I later thought about this and realized this would have also produced a sub-optimal output in the form of a potentially heavily stretched backdrop image.

I was able to come up with a good solution in time and it turns out I was thinking about it the wrong way. Rather than trying to scale up the backdrop image to fit the screen, it's easier and simply better to enforce a display aspect ratio that works for the game's artwork and scenes.

In my case, I need the aspect ratio of the game to never exceed 16/9 which led to the idea of simply clamping the player's view of the game to a 16x9 resolution, in other words, if the user's screen's width divided by their screen's height is greater than 16 divided by 9, then we must scale the display width of the game down to where it divided by the user's screens height is "equal" to 16/9 (equal is in quotes because I'm dealing with integer division when it comes to screen.width/screen.height so it's rarely truly equal)

To find the width to use, we only need to apply some fairly simple algebra: Let W be the user's screens width and H be the user's screens height. We must find W/H such that W/H = 16/9. Multiply both sides by H and we have W = 16/9 * H.

The screenshot below shows the code I wrote to clamp the users screen's resolution and it's based on the formula I proved above. In the if statement, I cast the screen width/height ratio to a float to make the comparison a bit finer tuned.

code_u8uep84u58.png

I'm sorry for my long infodump but hopefully someone found this helpful and can learn from what I've done here.



0 comments

Loading...

Next up

Been working on the visuals for the settings menu! I had the idea at the last minute to have the volume slider knobs each be different colored flowers which I think looks really cool. I left some space below them for extra options I may add in later.

Very small change, but I added a darker-green border to the edge where the grass meets the dirt. I think this gives a bit more definition to the transition between the two zones.

I spent a really long time on this, I've been here since literally 3 in the morning (it's 7AM as I type) but I really like how it came out!!! The backdrop I had done before didn't feel like it fit with the aesthetic so I re-did it completely.

Our 2024 Advent Calendar has opened! Day 18: @Otis_Le_PoOtis is the Creator of Bondee’s Barnyard and posts updates about their dev journey and their work on the sequel!) Accept the quest and give them a follow to get Coins and a seasonal sticker!

It's unfinished but the backbone of "The Garden" is now visible in the main scene! I want to add a lot more to this backdrop later today and over the coming week.

Happy #WIPWednesday!

Are you working on a game?

Making some art?

Practicing a song?

Something else?

Tell us in the comments!

It's kinda incredible how much simply changing the text font(s) will, by itself, complete the aesthetic of a game, especially in the menus.

I love TextMesh Pro so much!

I added an animation and sound effect when the player collects the heal-up drop. In the lore, this flower is going to be Hensen's favorite food which is why the sound effect is a crunch like he's bitten into something.

@Miles_Games is a Jolter to Watch! They post great game dev updates about the holiday-themed platformer TEAM SLAY-BELLS! Follow them before the quest ends on December 24 and you'll get Coins!

I have created a functional settings menu! I definitely want to spend some more time on the artwork for it but for now I'm satisfied. Everything seems to be working as it should.