Archived

This topic is now archived and is closed to further replies.

xjussix

How to implement a map?

Recommended Posts

How should I implement a map in my game. The map is made of squares and when the player selects a square it''s information is displayed in right side of the screen. I mean, the technical side of this..Should I use bitmaps and draw them to make the map or just dislpay this one big picture? Sorry if this is confusing..I''m a nuubiee. My first completed game! Where''s that???

Share this post


Link to post
Share on other sites
You would probably want to store them as seperate squares each square having its own structure attributes not sure which api you are using so I''ll try to keep this general.
  
class Tile
{
unsigned char *bitmap_data;
int width, height;
};
//Then for each bitmap you load do something like

Tile tiles[10]; //10 graphics

when loading the bitmap store the info into tiles[whatever graphic # youre on].bitmap_data

then you can have a text file with like numbers from 0-9 such as
1 1 1 1 1 1 1 1 1 1 1 1 1
2 4 6 1 3 8 4 2 9 2 3 5 7
2 3 5 8 3 2 1 7 4 2 3 8 3
then just read that file into something like unsigned char Map[3][13]; then when youre doing your drawing loop just do like
draw(Tiles[map[y][x]]);
This is just a pretty basic outline There are TONS of more articles on the net and in gamedev.net under articles and tile based Have fun I dunno if I answered your question hopefully I did!!! Got anymore questions just ask. (btw)tiles also take up a lot less memory then big pictures since you can reuse tiles and its easier to modify the map if it was one big picture then you would have to redraw the WHOLE THING!!! just cut it up into little images you can use later for something else

Share this post


Link to post
Share on other sites
Alrigth, thank''s man! This helped me alot! Btw. I''m using DirectX 7. I better get back to the coding stuff now.

My first completed game! Where''s that???

Share this post


Link to post
Share on other sites