This is quite comprehensive, but it doesn't appear specific to DX or any graphics API:
http://www.gamedev.net/reference/art...article728.asp
Some questions; does the game need to have 3D? You say DirectX, which implies 3D, but it wouldn't have to be 3D to be DirectX.. If not 3D, does DirectX include DirectDraw? From experience a long time ago, it's easier to make tile-based games ( with 2D graphics ) in DirectDraw than DirectX 3D.
Tile based engines are often used in environments where memory ( both in offscreen buffers and on disk ) is limited; traditionally, they have been used for 2D games, but the same principles can be used in 3D; since potential-or-impossible ( broadphase ) collision pruning is very easy when using tiles, and they generally favour games which are restricted to two dimensional movement, which this appears to be.
The tutorial link above uses multiple 2D arrays in the grid. I wouldn't recommend this. Use either a single 2D array of structures or pointers to structures; which store (if 3D) a reference/pointer/index to the model that should be drawn, or if 2D, a reference/pointer/index to the graphical tile to be drawn. Include the solidity flag in that structure. Don't use an obj array; since you only have about 6 'objects' ( enemies, players, tokens, and door ) although, perhaps, put the items ( tokens and door ) into an 'obj' array like that tut suggests; since their positions are only updated during initialization and when they are collected; but do not put the enemies or player into the grid's obj array; since their positions are updated frequently, and cleaning those objects out of their current cell(s) and putting them into new cell(s) every cycle would take longer than checking distances between the three of them every cycle. I'd actually NOT use a 2D array, I'd use a dynamically allocated 1D array with a row/column offset, so each tile is stored sequentially and an index is defined as ( y * gridWidth ) + x.. because then the map can easily be resized based on variables rather than hardcode; but, a 2D array is probably easier to work with.
The 'grid' itself is really simple; the math involved is simple to, and is explained in that article. Drawing the grid is a case of iterating through each cell in the grid, and drawing whatever 3D object / 2D image that the grid cell references at the 2D coordinates which are unique to that grid cell, psuedocode:
/*
gridWidth and gridHeight are the dimensions of the grid ( cell coords into the array ), and cellWidth and cellHeight are the width and height of each cell of the array ( in drawing coords ), thus width of the entire 'map' in drawing coords is gridWidth * cellWidth; likewise for height.
*/
for( x = 0; x < gridWidth; x ++ )
{
for( y = 0; y < gridHeight; y++ )
{
Bitmap * bmp = gridcells[x][y].bitmap;
drawBitmap( bmp, x * cellWidth, y * cellHeight, cellWidth, cellHeight );
}
}
I can't remember any DirectX or DirectDraw and don't use MSWindows, but I'm assuming there's some function to draw bitmaps to screen/buffers ( there is in DirectDraw ), and that it's defined like:
drawBitmap( Bitmap * bitmap_to_draw, int left, int top, int width, int height );
In DirectX, it's harder, but still possible, because you have to draw little 3D objects ( pairs of triangles ) which are textured with the two halves of the bitmap that you want to draw.. At least, that's how I learnt to do it, which is why I said it's easier to 2D games in DirectDraw. If you have to actually make this game have 3D models in it; then you have no choice but to use DirectX; but in that case, you don't have to mess about with pairs of textured triangles, you have to mess about with huge arrays of textured triangles instead ^_-. The tile based stuff can still apply; just make sure each tile model is the scaled width and height of one tile, and place the origins of those models at the center of the grid cell that they are placed in.
Checking collisions between a sprite (player/enemy) and a tile (in the grid) is a case of examining the grid cell(s) that are closest to the sprite, using a pair of divisions to convert a position in 'drawing coords' to a position in 'cell coords'. Do that every time the sprite attempts to move (by calculating a temporary that shows the position (2D drawing coords) the sprite is about to occupy ( cell coords ), and checking the cells it would be in), if the sprite would move over a solid tile; do not update the sprites position to the temporary, if the sprite is ok ( non of those cells are solid ), set the sprites current position to the temporary position. Draw the sprites, in the same way as for the tiles, but the positions (drawing coords) aren't unique or based on cell column/row ids, they are probably stored in the structures/classes that represent the sprites.