Download Sample Chapters from Book
Transcript
© 2009 NURVE NETWORKS LLC “Inside the XGS AVR 8-Bit” Figure 16.4 – The Atari 2600 classic “Pitfall” along with some of the tiles templated. Referring to Figure 16.4, you can see how this system works. As an artist you might start by creating some sketches of the kinds of screen and levels you want then you might start drawing some mock ups of the imagery. Then at some point, you begin “ripping” the imagery into a set of common rectangular tiles usually 8x8 or 16x16 pixels in size and then template them into a “tile set” (Figure 16.4(b)) of bitmaps. Then from the set of tiled bitmaps you generate all your actual game screens. The memory savings comes from the indirection in this system. Instead of using the actual bitmap data, you use an index or pointer to the bitmap in the tile set, thus a tile map might consist of 40x24 tiles, each tile is represented by a single byte index (thus a total of 256 tiles can be represented) and each tile is 8x8 pixels, thus the final frame buffer image or bitmap image would be: Width Height 40*8 = 320 24*8 = 192 But, the amount of memory to represent the tile map would only be 40*24 = 960 bytes! Of course, each tile bitmap still consumes precious memory, but you don’t need that many of them. So depending on the game and how much data is redundant on each screen, you can get away with few bitmap tiles. This all sounds too good to be true? So, what’s the catch? Well, the catch is that since the graphics modes are tiled. You can’t place an image just anywhere you want, it has to be on the tile matrix aligned perfectly. Therefore, its very hard to move a character smoothly on the screen. Moreover, its very hard to move anything on TOP of the tile mapped image without replacing the tile at any particular location. Of course, there are tricks to do this, but they require “re-writing” the bitmap tiles themselves and using “tile animation techniques”. A more common solution is the use of “sprites”. A sprite is a bitmap image that is rendered on top of the tile mapped image; moreover, sprites move smoothly in most cases, support collision with each other and can be larger or smaller than the tile map bitmaps themselves. A good example of sprite use are say the ghosts in PacMan, the blue maze of PacMan is a tile mapped image, but the ghosts and PacMan himself are sprites, therefore, they can move freely around the image since they are rendered on top of the image without disturbing the tile map. Figure 16.5 shows a screen shot of PacMan for reference. 21