DirectX 9, C++... Let me set the scene:
- I have a 16:9 image.
- I have a 16:10 screen.
- I want the 16:9 image to be drawn so that it is vertically centred within my 16:10 screen.
- My 16:9 image is 1920 x 1080.
- My screen is 1920 x 1200.
float topOffset = ( 1200 - 1080 / 2 )
But what if my screen was 1400 x 900
I have to resize the image and get its new height, then do the above again:
float newHeightForScaledImage = ( 1080 * 1400 ) / 1920
Okay so now I have a topOffset for both widescreen cases. I draw all of my images and interactive objects at their ( y position + the topOffset ).
New problem is that the menu is also needed to take into consideration, so I use that systemmetricssomething call which returns 20 which I then subtract from the topOffset... Okay my drawing is vertically centred... perfect!
Question is, regardless of my entire game now being vertically centred (in the most crazy long hauled way possibly known to man), I can still draw outside of the game area into the black zone that now exists.
I know I am approaching this wrong, but I am too new to this to know any better.
How do you guys vertically centre your games if they are a different ratio to the artwork you have created for the backgrounds etc?