I'm making a tile game in c++. Right now when the game loads all the tiles place themselves based on:
tilesize -> they are squares so this is width and height
tile_count_x
tile_count_y
I have the following variables:
desktop_width
desktop_height
game_window_width
game_window_height
tile_count_x
tile_count_y
Based on these values, I'm looking for an algorithm that will set an appropriate window size given the desktop and tile_count constraints. Then within this, I want my tiles to have an offset that will border x% around the window which will basically decide the tilesize too:
Example: If I have 10 * 3 of tiles then:
______________________________
Window Title _[]X
------------------------------
| |
| [][][][][][][][][][] |
| [][][][][][][][][][] |
| [][][][][][][][][][] |
| |
------------------------------
I'm just not sure the formula required to do this.
EDIT (from comments):
- Tilesize changes, tilecountx and y are static
- I want the gamewindow to be as big as it can be given the desktop resolution, but I also want its aspect ratio to respect the tilecoutx and tilecounty
I found an example of what I mean, open up Minesweeper in Windows