Jump to content

  • Log In with Google      Sign In   
  • Create Account

Data structures for map and game objects


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Wintermute2   Members   -  Reputation: 105

Like
1Likes
Like

Posted 15 December 2013 - 02:03 PM

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.

 


The software said "Requires Windows98, Win2000, or better." So I installed Linux.

Sponsor:

#2 arka80   Members   -  Reputation: 1061

Like
0Likes
Like

Posted 16 December 2013 - 02:40 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS