Page 1 of 1

Need help with map storage

Posted: Sat Sep 28, 2013 6:22 pm
by OldRod
I am working on a multiplayer browser strategy/empire-building game

I have a 10x10 world grid. Each grid square is then divided into a 10x10 region grid, so there are 10K regions total in the game that could potentially be accessed. Now, not all of the regions will be available for players to build on (there will be dungeons, land obstacles, resource nodes, etc. on some).

How is the best way to store this data using PHP/MySQL?

Re: Need help with map storage

Posted: Sun Sep 29, 2013 6:33 am
by a_bertrand
It pretty much depends what is the content of each of those 10K "cell". Explain what you will put inside those cells and we can then try to help youl

Re: Need help with map storage

Posted: Sun Sep 29, 2013 12:48 pm
by OldRod
It will be one of a list of things:

Player settlement
Boss encounter
Dungeon
Empty Cell
Map obstacle (mountain, water, etc.)

The idea is the player will click on the grid square and interact with what is there through another screen.

I'm debating whether it would be best to just keep a table of the X/Y position and content of each occupied cell (which could get quite long as the game progresses), or some kind of byte-array that could be stored all in one record (not sure how to do this)

Re: Need help with map storage

Posted: Sun Sep 29, 2013 3:50 pm
by a_bertrand
If you run for something like NEaB, I took the road of RLE (Run Length Encoded) maps:

if you have 10 roads one after the other: you will find something like 10xRoad instead of Road;Road;Road.... That takes a lot less space. However it requires a bit more efforts to store / restore the maps.

Re: Need help with map storage

Posted: Wed Oct 02, 2013 1:07 pm
by OldRod
OK, I've been giving this some thought.

I have 100 world regions. Within each of these regions is 100 sectors. Would it be possible to represent the contents of each of those sectors as an array of 100 numbers (1=open, 2=mountainous, 3 = player settlement, etc.)? Then I would have a world table and for each of the 100 regions I would serialize the array for the sector data in that region and store it, along with the X/Y identifier of that region. Would that work?

I've never used serialize/unserialize. In a multiplayer environment where the map could be changing, will that cause any problems?

Re: Need help with map storage

Posted: Wed Oct 02, 2013 2:00 pm
by hallsofvallhalla
look at my forsaken sanctum web game videos and open source. It uses what you are looking for and is capable of millions of locations.

Re: Need help with map storage

Posted: Wed Oct 02, 2013 2:32 pm
by OldRod
hallsofvallhalla wrote:look at my forsaken sanctum web game videos and open source. It uses what you are looking for and is capable of millions of locations.
Thanks :)

Re: Need help with map storage

Posted: Fri Oct 04, 2013 4:28 pm
by Sharlenwar
hallsofvallhalla wrote:look at my forsaken sanctum web game videos and open source. It uses what you are looking for and is capable of millions of locations.
*goes to look!!!*