title: Tile sizing algorithm
body: <p>I'm making a tile game in c++. Right now when the game loads all the tiles place themselves based on:</p>
  
  <p>tilesize -> they are squares so this is width and height</p>
  
  <p>tile_count_x</p>
  
  <p>tile_count_y</p>
  
  <p>I have the following variables:</p>
  
  <p>desktop_width</p>
  
  <p>desktop_height</p>
  
  <p>game_window_width</p>
  
  <p>game_window_height</p>
  
  <p>tile_count_x</p>
  
  <p>tile_count_y</p>
  
  <p>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:</p>
  
  <p>Example:
  If I have 10 * 3 of tiles then:</p>
  
  <pre><code>______________________________
  Window Title              _[]X
  ------------------------------
  |                            |
  |    [][][][][][][][][][]    | 
  |    [][][][][][][][][][]    |
  |    [][][][][][][][][][]    |
  |                            |
  ------------------------------
  </code></pre>
  
  <p>I'm just not sure the formula required to do this. </p>
  
  <p>EDIT (from comments):</p>
  
  <ul>
  <li>Tilesize changes, tilecountx and y are static</li>
  <li>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</li>
  </ul>
  
  <p>I found an example of what I mean, open up Minesweeper in Windows</p>