Design question about maps
I'm developing a game that will employ a large world map. This map will have sections on it where different things will happen (player walks into a section of type "water", colors change, and so on).
I'll need to define a large number of sections like this, and they will be a large variety of shapes and sizes - no simple boxes. The same section will have the same position every time - these sections will not change during gameplay.
Of course, I'm going to start small first. However, I'd like to make an optimal design so that if I scale the project up, I won't need to rebuild the project.
I need to define these sections, in some relatyion to the map.
My initial thought was that each square in my map could be defined as a type in a database- coordinate 1, 1 is "Water", and so on. Now this makes for an easy check to see where the player is: store the visible squares in a 2d array (so I don't have to query a db ALL the time), then look up where Player is at in the array, and get the type.
This works on a small scale, but if I want to expand my game map to 1000x1000 or 10000X10000 or bigger, I'm going to run into MAJOR performance problems (I expect - right?)
So I need another more effective approach that will work on a large scale. I am thinking about defining a section as a polygon (with a list of points), but I'm not sure how to store it, or how to check it if I'm in it or not.
Can anyone offer some guidance? Surely the database model (or 2d array model) would breakdown as the game expanded, right?
Re: Design question about maps
The 2D array would work alright as you say for a smaller type of game, however when the actual map starts to scale up to the size where it is no longer viable having it all in memory any more you might want to have a look at height maps.
Heightmap - Wikipedia, the free encyclopedia
Height Map Editor Home