Jump to content
  • Advertisement
Sign in to follow this  

Data structures for map and game objects

This topic is 2138 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



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;
fResources : array[0..2] of TResource;
//number of idle citizens
fIdleCitizens : integer;
//industries (buildings)
fActivities : TList;
fPlayer : TPlayer;
//province identifier
fProvince : TProvince
fHasCity : boolean;
fArmies : TList;
fVisible : boolean;

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.




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

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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!