We want to draw (quite) complex things, starting from simple ones, the easier way to accomplish that is to use tiles (at least one used quite often), so we don't draw the full image, but just small pieces, with many pieces we can draw complex images, I'm going to use three (virtually four) layers of tiles:
- The base ground: Sand, grass, water, etc.
- The ground objects: Rocks, trees, a road, a volcano, etc.
- Things that can lay on the ground: Treasures , any other inventory-related object, etc.
- On a virtual 4rd layer we will draw additional objects, not map-related such as PCs, NPcs, the mouse cursor, etc.
Not very impressive right? but it shows the key to build complicated maps using simple tiles, divide an image into small pieces and use layers, we have applied here the latest updates to the simple engine class in the previous posts.
The basic difference between this projects and the life game one is that in the previous one the map was an array with two dimensions: cellmap[x][y], now it is a three dimensions map: map[x][y][layer], so when we draw the map we will have to draw first layer (0) to print the base ground, then layer(1) for the terrain objects and finally layer(2) to draw other objects, after we have drawn the map we will draw the mouse pointer.
Note: there are many , many ways to define and draw a map, here i have just used a simple way.. you can find more ways for example in Amit's game programming information but of course, you can use anything that meets your objectives.
In the next post: Our Hero drawn on screen, cameras , and other things....