Isometric Tiles
Isometric tiles are the basis of many real-time strategy (RTS) games, war
Isometric tiles give an artificial sense of depth as if the player's viewpoint is somewhere up in the sky, looking down over the playing area. Of course, this view is artificial since no perspective effects are applied; the tiles in the row "
The illusion that each row of tiles is further back inside the game is supported by the z-ordering of things (
There are various ways of labeling the x-axis and y-axis of a isometric tile map. I'll use the standard
Figure 13-2. A staggered isometric tile map
Odd and even rows are offset from each other, which means that the tile coordinates can be a little tricky to work out as a sprite moves between rows. AlienTiles uses tile coordinates to position sprites and other objects on the surface. However, the surface isn't made from tiles; instead, it's a single medium size GIF (216 KB), as shown in Figure 13-3. Figure 13-3. The surface.gif image
Most isometric games construct the surface from individual tiles, which allows the floor space to be rendered incrementally and to change dynamically over time. The drawback is the increased complexity (and time) in drawing the tiles to the screen. Drawing the individual tiles in back-to-front row order is necessary, with each diamond represented by a rectangular GIF with transparent corners. The coding problems are like the difficulties detailed in Chapter 12, with positioning
Often, the surface will be a composite of several
Movement
AlienTiles
offers four directions for a sprite to follow: northeast,
The
Figure 13-4. Directions of movement for a sprite
The range of directions is dictated by the tile shape, to a large extent, and diamonds aren't the only possibility. For instance, a number of strategy games use hexagons to form a Hex map (Figure 13-5), which allows six compass directions out of a tile. Figure 13-5. A hex map
Movement around an isometric tile surface is often based on single steps between tiles. It's not possible for a sprite to move about inside a tile; the sprite can only stand still on a tile or make a single step to an adjacent tile. In AlienTiles , a key press causes a single step, and the user must hold down the key to make the sprite sprint across several tiles. A key press triggers a method call to update the sprite's position, which is updated onscreen at 40 FPS.
Though I talk about a player moving around the surface, the truth is that the user's sprite doesn't move at all. Instead, the surface moves in the
As with a side-
Placing a Sprite/Object
Care must be taken with object placement so the illusion of an object standing on top a tile is
Figure 13-6. Placing a sprite onto a tile
The sprite can occupy screen space above the tile but should not overlap the bottom left and right edges of the diamond. If it does, the image will seem to be partly in the
The Tile Map SurfaceThe AlienTiles surface contains no-go areas that the sprites cannot enter. These include the ocean around the edges of the tiled surface, a lake, a pond, and four red squares (all visible in Figure 13-1). The no-go areas are defined in a configuration file read in by AlienTiles at start-up.
The game surface has two kinds of objects resting on it:
blocks
and
pickups
. A block fully occupies a tile, preventing a sprite from moving onto it. The block image can be anything; I
Blocks and pickups are harder to implement than no-go areas since they occupy space on the game surface. This means that a sprite can move behind one and be partially hidden. Pickups pose more problems than blocks since they can be removed from a tile.
More sophisticated games have a much greater variety of surface objects. Two common types are
walls
and
portals
(doors). A wall between two tiles
The
|
|
In general, alien design opens the door to