Jump to content

  • Log In with Google      Sign In   
  • Create Account


What is the best way to work with map data?


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
2 replies to this topic

#1 arrow62   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 January 2000 - 05:56 AM

I am making a tile based strategy game in C++ and Directx and was wondering what the best way was to work with map data. I have considered just putting the data into arrays but since I will need to store 3-4 layers(base tile, terrain, forest, roads, etc...) as well as resource data and perhaps other things. Is there a more object oriented approach that would still be efficient? I''m curious how others are dealing with this. Any comments would be appreciated.

Sponsor:

#2 Fuge   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 January 2000 - 04:18 PM

Here''s a more object-oriented approach that I used on one of my engines. I did end up using arrays, which I found to work quite well. In this particular game I was using 32x32 tiles on a screen of 640x480, so I had a screen array like this:
Screen[20][13]

Based on that, I created this structure:

struct MAP_TILE
{
base_tile[20][13];
fringe_tile[20][13];
obj_tile[20][13];
}

The main map was then created like this:

MAP_TILE LevelMap[20][13];

To access a particular tile layer (for example, on screen 13, 2) in the map array, I did it like this:

LevelMap[12][1].base_tile[20][13];

That''s mainly it for how I did the actual data storage. Like I said, it may not be the most optimal way of doing this, but it worked just fine for me. If you want more info on how I did it, I''d be happy to show you how.

- Fuge
(jonathan_morris@hotmail.com)




#3 Fuge   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 January 2000 - 04:24 PM

Oh! One thing I just noticed. I listed the initialization of the MAP_TILE array as
LevelMap[20][13]

I hope that didn''t confuse you. The game I had done was a Zelda-style RPG so only one screen was shown at a time and the scrolling was fron screen to screen. That was why my array was [20][13]. In all truth, your game may do the arrays sizes quite different, but the OOP approach remains the same.




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