Archived

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

cozman

Is this a good starting class for a tiled map?

Recommended Posts

cozman    583
I''m working on a map and this is my class so far: enum TileType{TT_BLANK = 0, TT_GRASS1 = 10, TT_GRASS2, TT_GRASS3, TT_WATER1 = 20, TT_WATER2, TT_WALL1 = 30, TT_PATH1 = 40, TT_SNOW1 = 50, TT_MAX}; enum TileCeil{TC_NONE = 0, TC_TEMP = 10, TC_MAX}; enum TileStr{TS_FLOOR = 0, TS_WEAK, TS_STRONG, TS_SPECIAL, TS_PERMANENT, TS_MAX}; enum TileArea{TA_TOWN = 0, TA_ARMORY, TA_HOTEL, TA_HOUSE1, TA_HOUSE2, TA_HOUSE3, TA_HOUSE4, TA_HOUSE5, TA_AUX1, TA_AUX2, TA_AUX3, TA_MAX}; class Tile{ private: TileType Type; //type of tile (for picture) TileCeil Ceiling; //ceiling of tile (for picture) TileArea Area; //area that tile is member of TileStr Strength; //Strength of tile unsigned int EventNum; //Event Identifier void SetType(TileType NewType, TileCeil NewCeil); //Sets types void SetStrength(TileStr NewStr); void SetArea(TileArea NewArea); public: Tile(void); void Init(TileType NewType, TileCeil NewCeil, TileStr NewStr, TileArea NewArea, unsigned int EventForTile); /*Accessors*/ TileType GetType(void) { return Type; }; TileCeil GetCeiling(void) { return Ceiling; }; TileStr GetStrength(void) { return Strength; }; TileArea GetArea(void) { return Area; }; unsigned int GetEvent(void) { return EventNum; }; bool IsWall(void); bool HasCeil(void); }; Is that going to work to make a tile map? I think I covered everything but just in case I didn''t I don''t want to get too far w/ something that has a major flaw. Thanx in advance . "this one time at computer camp..."

Share this post


Link to post
Share on other sites
JackNathan    122
Well you are the only one that knows what your tiles need to represent. But for a good starting place -- why not use the absolute minimum you need to get something working and then expand. i.e. Just the graphic. Also I''d suggest using a database program and making a database of your tile types -- read that (or a text export) into the game.


Jack

Share this post


Link to post
Share on other sites
Kylotan    9881
Looks fine to me. My personal recommendation would be to have all function bodies in the .CPP file though, as I like to avoid unnecessary recompiles, but if you feel they need inlining, so be it.

Share this post


Link to post
Share on other sites
cozman    583
jacknathan- i made a very basic image based tile engine before, and yes, i am reading in values from a text file for initialization.

kylotan- thanks for the tip, i moved them over.

Share this post


Link to post
Share on other sites
Possibility    122
It looks very good, and I would keep those functions in the header as inlining like that is faster. Also, I usually have the X and Y position (array index) of the tile on the map in the tile class also, it surprisingly comes in very handy.

Possibility

Share this post


Link to post
Share on other sites