Of Screen Resolutions and Minimaps

If you ever see the code for ABC-Pop (not if I can help it). You would soon became rationally angry at my design choices. And then, very soon - irrationally angry.

In my previous post I wrote about camera-pan movement and render to texture functions in which I rendered entire level to a texture and then just rendered the camera view to the screen. Well, when I was developing ABC-Pop, I never knew about SDL_SetRenderTarget function (in hindsight, it's obvious) and I soon encountered the problem of handling my UI and game rendering for multiple resolutions.

A sane mind would go on the net and search about handling UI rendering and game rendering against unknown target resolutions.

Not me.

I like to invent and discover stuff for my self. But sometimes instead of discovering hot water, you end up discovering piss. And that was what I did for ABC-Pop. So instead of heating water to boil, I pissed in the pan and called it hot.

Okay, enough metaphors. I made my entire game work with percentages. So when you see the main window "Start Game" button in ABC-Pop you can be sure that it's made with.

start_x = GetPercentage(WINDOW_W, 10)
start_y = GetPercentage(WINDOW_H, 10)
end_w = GetPercentage(WINDOW_W, 80)
end_h = GetPercentage(WINDOW_W, 20) 

Every. Single. Window Button. Is. Made. Like. This.

Needless to say, I spent more time making sure that ABC-Pop UI work well in most resolutions than I spent programming the game itself.

It was not until I was working on Critters and camera-pan functionality that I was presented with a problem of rendering a part (camera view) of the level to the screen.

So a week later, when I started to recover from my head-table contacts (I need a new table btw), I realized that I can very easily use the RenderToTarget function to render a minimap as a part of the game's HUD.
The rationale being, that I just render the Critters position on a separate texture and then render it resized on screen.
And it works. And now. The Critters have a functional minimap display.


Minimap 




 If you're interested in Critters or find this blog moderately interesting,
You can follow me on Twitter for news and updates
https://twitter.com/CrittersDev








Comments

Popular posts from this blog

Trouble in Qt Paradise

Programming UI for Critters

Of Loot Bombs and Sticky Walls