Screen Scaling

Unity
Unity

So I’ve been quietly working on the next project in the Udemy course which from what I gather is a Plants vs. Zombies clone.  Once again, this project builds on the previous ones and piles on the difficulty.

The one area that managed to baffle me was the concept of screen scaling and how to fail over gracefully between the various screen sizes.  You’d think after almost 2 decades of web development I’d be used to this concept, but the path chosen here is slightly different.  Where I would scale a web page up or down and based on the target resolution, the approach in this project is to basically create a game space with a core area that is always preserved and just display useless (but consistent) imagery outside of that space.

The light grey area is our game space. Ignore the win/lose buttons as they were just for testing.

On top of that, for the first time we were working with a tiled background.  A lot of math went into configuring this screen so that the core game space (highlighted in light grey) was 5 squares high and 9 squares wide, that each of the squares were actually square and that the background continued to draw itself beyond the playable area.  Also everything is set up so that the perfect center of the bottom left square in the game space is at position 1,1 and the top right is position 9,5 which makes placing game objects in the right spot incredibly easy.  I’ve watched this lesson a couple of times now, and I’m still not convinced I could work this one out on my own.  I’m going to watch it again before I finish this project up just to drive these lessons home.

Again, I’m just getting through these lessons for the time being.  I do feel that what they’re teaching is important and an excellent foundation, but I’m hungry to learn as much as I can in the limited free time I have available.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.