Game
Hensen Hopper
1 year 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

I am impressed by my past self right now. The algorithm behind the unimplemented dashing mechanic (that I wrote like a year ago) uses a sine wave to smoothly increase/decrease Hensen's movement speed for a dash. That is so clever! I actually wrote this!?

I made some updates to the hints system! Now it reads from the message hub to determine when to show hints and the hint texts now come from the lang system I wrote yesterday. This simplified my the hints handling algorithm A LOT from what it used to be!

The beetle shell is now fully VISUALLY implemented! Next thing on my list is a unique sound for Hensen equipping it.

Doki Doki Literature Club is celebrating Monika's birthday and the 8th anniversary of DDLC with exclusive stickers, avatar frames and backgrounds on Game Jolt! 

Head over to the shop to collect yours 👉 https://gamejolt.com/#shop

I've been working on some proper visual art for the beetle shell when it's equipped! I've also gone ahead and drawn a break animation for it. All I need to do now is actually set all of this up in Unity which I'll probably do on Tuesday.

Dive into the cozy post-apocalyptic open world of Critter Cove!

Gentleman Rat Studios (@GR-Rob ) describe it as “a little bit Animal Crossing, a little bit Stardew Valley. Maybe even a little bit Windwaker, too."

Wishlist the game: https://bit.ly/CritterCove

Here's a short demonstration of the beetle shell power-up in-action! It's not very obvious what it does at the moment because I still need to work on a lot of the effects for it, but the functionality is there if you pay attention to the health bar!

Oh yeah, also, I updated that algorithm for dash handling I shared yesterday so I can set the dash duration via the inspector window!

Mae Borowski is the main character of Night in the Woods! It's an adventure game that tells the story of her return to her hometown of Possum Springs. She was confirmed as canonically pan in a social media post by the game's creator Scott Benson.

I've decided to have the statistics behind the quests in Hensen Hopper be handled as actions reported to the quest manager rather than try to write variables into a whole bunch of scripts solely for quests.