Sign In Register

How can we help you today?

Start a new topic
Answered

Tile editor, saving data.

 I'm very new to BaaS and Game Sparks entirely, but I've searched the forums and am only getting glimpses of the proper way to handle this. 


In my scenario, I have approximately 16000 tiles that can be edited by the players.  So of course, in the first time a player plays, I want to set these tiles to a certain default value.  This should call some initialized data set that gets sent to the client to initialize the types of tiles.  Then every time the player changes something, I want to update those values on the server.  Then just load the newest one every subsequent play. 


Tiles only need a few details:


int id;

int terrainType;

int tileType;

bool locked;


What is the proper way to store 16000 sets of this type of data structure?



Best Answer

 Hey Jon,

There isnt too much wrong with with method, but i would keep aware that the size of the response is limited to 4MB so you might have to paginate the request.

You also do have a recommended limit to the data-per-player you can store based on our fair-use policy.

Other than that, its easy.
Just create an event to request the data and store the data in a document with the playerID so it looks something like this....



 

 

{
"player_id" : "456kXXXXX",
"tiles" [

{
id :  0,
terrainType : "sand",
tileType : "agr",
locked : false

},
{
id : 1
terrainType : "sand",
tileType : "agr",
locked : false

}


]

}

 

 


This way you can query for the player's maps and get the tiles down to the client in whatever order you want.

Does that help?
Sean



Hi Jon,


Is this 16000 tiles per player ? So a players stored data would amount to these 16000 documents associated with their account and they edit these over time during gameplay ? Or do you mean 16000 shared between the entire player base ? 


Thanks,

Liam

The map is unique to each player. Basically, imagine a game like Township where you can change the maps tiles from grass to dirt or add a street etc. that map is unique to that client. A 2d array of a struct would work but that's a lot of data on the device plus I want it to persist, not to mention trying to keep it off the client so locked tiles that shouldn't be edited need a final say from the sever. What's the proper way to handle this?
Anyone?
Answer

 Hey Jon,

There isnt too much wrong with with method, but i would keep aware that the size of the response is limited to 4MB so you might have to paginate the request.

You also do have a recommended limit to the data-per-player you can store based on our fair-use policy.

Other than that, its easy.
Just create an event to request the data and store the data in a document with the playerID so it looks something like this....



 

 

{
"player_id" : "456kXXXXX",
"tiles" [

{
id :  0,
terrainType : "sand",
tileType : "agr",
locked : false

},
{
id : 1
terrainType : "sand",
tileType : "agr",
locked : false

}


]

}

 

 


This way you can query for the player's maps and get the tiles down to the client in whatever order you want.

Does that help?
Sean


Login to post a comment