• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
schupf

UI components: Scaling

5 posts in this topic

Hello,

I have made a little UI system to render UI elements (button, combo boxes etc.) in my DirectX 9 game.

Now I struggle a little bit with scaling of my components. To make my problem more clear I made a sketch:
[sharedmedia=core:attachments:12412]
Lets say I start my game windowed with resolution of 2000x1000. The red rectangle is my UI component. Now If i resize the window down to 1000x500 I guess it would be desirable to scale down the UI component proportionally.
So my algorithm could be something like this: After resize of window, resize all UI components proportionally horizontally and then vertically.

But then I have a problem when the user only applies a resize of the window in one dimension (bottom image). If I applied my algorithm the UI component would be distorted - clearly something I do not want.

So how could I implemented a solid scaling mechanism that scales my UI elements when the resolution changes?

Thanks!
0

Share this post


Link to post
Share on other sites
Windows handles this with the WM_SIZING message, actually providing information on the element used to resize. An easy fix for you would be to handle horizontal and vertical scaling separately. When your window changes size, recompute the horizontal scale factor, apply it to the width of your ui elements, and do the same thing with vertical/height. Also realize, you may not want everything to be sizable. Buttons are drawn at the scales they are drawn for a reason, if you shrink them too much, you will find it hard to click, and if you grow it too much, you lose the real estate you gained by scaling the window in the first place. Text will not handle scaling much at all, especially a one dimensional scale.
0

Share this post


Link to post
Share on other sites
have a 2 component scale + 2 component pixel offset for both position and size, which allows you to place gui elements lets say 5 pixels from any edge of the screen no matter what resolution, or keep it x pixels high but scale width with resolution.

Also allow the scales to be proportional to either the corresponding axis of resolution, OR both scale axis proportional to only 1 resolution axis like x and y.
0

Share this post


Link to post
Share on other sites
We've handled various resolutions in a few ways.

Probably the best is to have the UI based on the corners and center lines of the screen, scaled (keeping their aspect ratio) based on resolution. A long narrow screen like you posted means there is a bigger gap between the left and right side, and the screen height is the controlling scale factor.

Another is to normalize the screen to a fixed aspect ratio, drawing black bars over the two sides that are out of bounds. The entire screen could be based on a 4:3 aspect ratio, and any other display ratio gets black bars.
0

Share this post


Link to post
Share on other sites
@frob: Could you please elaborate your first approach a little bit more? Do you mean I determine whether I scale a component based on the smaller dimension of the window?
0

Share this post


Link to post
Share on other sites
[quote name='schupf' timestamp='1353532981' post='5003027']
@frob: Could you please elaborate your first approach a little bit more? Do you mean I determine whether I scale a component based on the smaller dimension of the window?
[/quote]
Let's try an example.

We'll have a button bar, built as a 600x100 strip, rooted at a corner, occupying up to 40% of the screen horizontally and up to 10% of the screen vertically.


Let's start with a 640x480 screen.

40% * 640 = 256px max width
10% * 480 = 48px max height
The width is the constraining value, so the UI element scales to become a 256x42 px bar.

Let's try with a 1024x768 screen
40% * 1024 =409px max width
10% * 768 = 76px max height
The width is the constraining value, so the UI element scales to become a 409x68px bar.

Let's try with a widescreen 1680x1050 screen
40% * 1680 = 672px max width
10% * 1050 = 105px max height
... Things just got interesting ...
Neither value constrains.
So we can choose to scale, height is the constraining value so we scale up to 630x105
Or we can choose to not scale, making our 600x100 button bar full size regardless of the larger screen space.


The titles I've worked on that did this always used normalized screen coordinates. So the UI element may have the UI element's corner be rooted at (0,0) or (1,1) or some other corner, or it may have it's center point rooted at (0.5, 0.5) to be exactly centered, or perhaps a little experience shows you should be a little higher on the screen with its center point rooted at (0.5, 0.4).

All the UI elements can be specified in an XML configuration file or other scripts so designers can manipulate them. They are also named constants so it is easy to move as a batch.



Naturally this format has its own set of drawbacks; all layout systems have their own sets of pros and cons.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0