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?
Need help with map storage
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: Need help with map storage
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
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: Need help with map storage
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)
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)
- a_bertrand
- Posts: 1536
- Joined: Mon Feb 25, 2013 1:46 pm
Re: Need help with map storage
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.
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.
Creator of Dot World Maker
Mad programmer and annoying composer
Mad programmer and annoying composer
Re: Need help with map storage
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?
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?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Need help with map storage
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
Thankshallsofvallhalla 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.
- Sharlenwar
- Posts: 523
- Joined: Mon May 28, 2012 7:14 pm
Re: Need help with map storage
*goes to look!!!*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.
Deep within the Void of Quasion, a creation.
**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG