title: Planning a 2D tile engine - Performance concerns
body: <p>As the title says, I'm fleshing out a design for a 2D platformer engine.  It's still in the design stage, but I'm worried that I'll be running into issues with the renderer, and I want to avoid them if they will be a concern.</p>
  
  <p>I'm using SDL for my base library, and the game will be set up to use a single large array of <code>Uint16</code> to hold the tiles.  These index into a second array of "tile definitions" that are used by all parts of the engine, from collision handling to the graphics routine, which is my biggest concern.</p>
  
  <p>The graphics engine is designed to run at a 640x480 resolution, with 32x32 tiles.  There are 21x16 tiles drawn per layer per frame (to handle the extra tile that shows up when scrolling), and there are up to four layers that can be drawn.  Layers are simply separate tile arrays, but the tile definition array is common to all four layers.</p>
  
  <p>What I'm worried about is that I want to be able to take advantage of transparencies and animated tiles with this engine, and as I'm not too familiar with designs I'm worried that my current solution is going to be too inefficient to work well.</p>
  
  <p>My target FPS is a flat 60 frames per second, and with all four layers being drawn, I'm looking at 21x16x4x60 = 80,640 separate 32x32px tiles needing to be drawn every second, plus however many odd-sized blits are needed for sprites, and this seems just a little excessive.  So, is there a better way to approach rendering the tilemap setup I have?  I'm looking towards possibilities of using hardware acceleration to draw the tilemaps, if it will help to improve performance much.  I also want to hopefully be able to run this game well on slightly older computers as well.</p>
  
  <p>If I'm looking for too much, then I don't think that reducing the engine's capabilities is out of the question.</p>