New Demo - Refactored Tile Engine + Rotating Grid

Saturday, 1 September 2007 | | |

Whilst graphicly nothing new this demo shows the rotating grid concept in the tile engine. First I'll summarize the how the engine works with regard to level layout and design.

The Engine itself is a Sprite that has 3 Sprite Children.

  • Lowest Sprite - the particle engine
  • Middle Sprite - the world object sprite, this contains the player, enemies, the demo 'boxes'
  • Top Sprite - the level itself
I use the scrollRect method on the Engine sprite to scroll the entire display list. One of my requirements was very large levels > 1000x1000 tiles. Whilst this can be draw a series of bitmaps and displayed at once I would not recommend it: I tested a 500x100 level with 48x48 pixel bitmaps merged into 8x8 super tiles ( 576Kb bitmap ) = 63x13 super tiles = >471Mb of bitmap data. It actually did work but I would not recommend it...

Another option would have been to iterate over my map array, and use copyPixels to draw the level. This is probably the most common method of scrolling bitmap level. However, you still need to efficiently manage your Bitmap & BitmapData objects - that's where the grid comes in. In the example (link at the end of this entry), there is only ever the same 9x9 Bitmaps on the sprite ever. As the grid is rotated, the bitmap object is repositioned and its bitmapData member set to a new values based on an update. You could think of it as a recycling object cache.