Storing "unit" information
struct MapObjUDT{ cMapObj *MapObj; //Pointer to a generic map object base class cMapObjUDT *NextNode; //Pointer to the next node}struct MapPtUDT{ MapObjUDT *ObjList; //Pointer to the list head long Flags; //Various flags for this spot};
With my map engine, everything is a map object (Tiles, static objects like trees, and entities). Most of the time the very first object is the tile. What this whole system allows you to order any of the objects anywhere so you could actually have multiple levels over any given point and people walking between them.
There are a few things that need to handle that are a bit out of the ordinary, but nothing serious that anyone who has ever dealt with linked lists can't handle.
Good Luck and I hope this helps!
PS: HI TANSTAAFL!
------------------
Dino M. Gambone
http://www.xyphus.com/users/dino
Good judgement is gained through experience. Experience, however, is gained through bad judgement.
Dino M. Gambone
Good judgment is gained through experience. Experience, however, is gained through bad judgment.
Currently working on Rise of Praxis MUD: http://www.riseofpraxis.net/
I'm designing a simple tile based game, and was wondering what the best method to store "unit" information was? An array or linked-list would do, but wouldn't that be a big slow down having to search through ALL the "units" just to find the ones on the current screen? Are there any better ways of doing this?
Thanks a lot
Lloyd
An advantage to arrays over link lists is knowledge of worse case memory requirements as well as increased locality of references. It also makes your life a lot easier if you happen to be using a transparent garbage collection library.