• Advertisement
Sign in to follow this  

Data structures for map and game objects

This topic is 1500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I am programming a turn based strategy game in Free Pascal.

 

The map is composed of cells grouped into provinces. But unlike other games, each land cell is inhabited and could have industries and produce resources.

 

For the first version I simply created a MapCell class :

TMapCell = class
//terrain type
fTerrainType : byte;
//resources
fResources : array[0..2] of TResource;
//number of idle citizens
fIdleCitizens : integer;
//industries (buildings)
fActivities : TList;
//player
fPlayer : TPlayer;
//province identifier
fProvince : TProvince
//city
fHasCity : boolean;
//armies
fArmies : TList;
//visibility
fVisible : boolean;
end;

The map is simply a 2D array of map cells, displayed with a 2.5D isometric view.

 

To display the map I would loop through the array.

 

But I read a few articles and I am wondering if it is the right way to do.

 

http://www.gamedev.net/page/resources/_/technical/game-programming/tile-based-games-faq-version-12-r728
http://archive.gamedev.net/archive/reference/articles/article727.html
http://www-cs-students.stanford.edu/~amitp/Articles/TileMultipleObjects.html
http://archive.gamedev.net/archive/reference/programming/features/gpgenesis8/page3.html

 

Maybe I should separate graphics (terrain, transitions...) and gameplay data (population, industries, buildings...). The map would be composed of several arrays (on for each layer).

 

Thank you for your opinions and advice.

 

Share this post


Link to post
Share on other sites
Advertisement

I think there's nothing wrong with your design: it's quite useful to have all needed data of a cell in a single place. Maybe you can consider to move from that data structure all not static stuff... for example, if Armies are something that moves along the cells it can be better to remove them from the mapcell and put in a separate array, with the reference to the current cell as a simple position.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement