A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Best way to store game map data in Mysql?

  1. #1
    Senior Member Boombanguk's Avatar
    Join Date
    Jun 2000
    Posts
    1,194

    Best way to store game map data in Mysql?

    Hi,

    I'm working on a game that will be isometric tile based, and will have an array (large array maybe some 8000 elements, each of the elements containing objects made up of maybe 12 items), I need to be able to store this array for each user but I'm not sure the best to do it, so my questions are..

    1) Is it possible to store this array inside a mysql database and if so how, and what's the best way of doing that?

    2) Is it better to store the data inside a file (.txt? although I don't see that being very secure) that the database accesses?

    3) Would AMFPHP get involved with this process at any stage?

    4) Would an array of that size take a while to load/save?

    thanks for any help.
    FlashGameMaker.com - er..where I say stuff.

  2. #2
    Member
    Join Date
    May 2009
    Location
    Ahmedabad, GUJARAT, INDIA
    Posts
    31

    my opinion

    HI Boombanguk,

    As per my opinion dont store data in txt file

    store array as text in mysql, you can do it via amfphp also or you can use phpdiractly.

    you have to load data through xml its not take more time

    Thanks,
    Kunjan

  3. #3
    Senior Member Boombanguk's Avatar
    Join Date
    Jun 2000
    Posts
    1,194
    Quote Originally Posted by kunjan View Post
    HI Boombanguk,

    As per my opinion dont store data in txt file

    store array as text in mysql, you can do it via amfphp also or you can use phpdiractly.

    you have to load data through xml its not take more time

    Thanks,
    Kunjan
    But I thought 8000 nodes or whatever it is in XML, would take a good long while to loop through, I'm not sure how to store data via amfphp in a database anyway.
    FlashGameMaker.com - er..where I say stuff.

  4. #4
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Use JSON to serialize your data or write your own custom serialization code and treat the array as a blob of text, store it anywhere you like and deserialize it (back into an array) when you retrieve it from the database. If your data is simple the serialize/deserialize code will be pretty trivial (basically calling Array.toString and String.split).
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  5. #5
    Senior Member Boombanguk's Avatar
    Join Date
    Jun 2000
    Posts
    1,194
    Quote Originally Posted by Northcode View Post
    Use JSON to serialize your data or write your own custom serialization code and treat the array as a blob of text, store it anywhere you like and deserialize it (back into an array) when you retrieve it from the database. If your data is simple the serialize/deserialize code will be pretty trivial (basically calling Array.toString and String.split).
    And does the mysql database simply reference that file for each user? or is it somehow included inside the database in serialized form? So it wouldn't be a good idea to store the array as a large xml file?
    FlashGameMaker.com - er..where I say stuff.

  6. #6
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    You'll serialize it and then store it wherever you like. If you're not familiar with MySQL or amfphp then the learning curve may be too high to deal with it. You'll be fine storing JSON formatted data in a flat file (text file) and you shouldn't run into any trouble with speed since json is compact and anything can read it; javascript, flash, php or whatever.

    I don't know what version of AS you're using, nor do I know that AS3 can parse json but a simple request for the file and the JSON library from the JSON website will do the trick.

    If you do use mysql then store the data there, don't use it to refer to flat files.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  7. #7
    Senior Member Boombanguk's Avatar
    Join Date
    Jun 2000
    Posts
    1,194
    Quote Originally Posted by mneil View Post
    You'll serialize it and then store it wherever you like. If you're not familiar with MySQL or amfphp then the learning curve may be too high to deal with it. You'll be fine storing JSON formatted data in a flat file (text file) and you shouldn't run into any trouble with speed since json is compact and anything can read it; javascript, flash, php or whatever.

    I don't know what version of AS you're using, nor do I know that AS3 can parse json but a simple request for the file and the JSON library from the JSON website will do the trick.

    If you do use mysql then store the data there, don't use it to refer to flat files.
    My project is a AS3 project in Flash Builder 4. I've used Mysql a bit in the past so I have some idea of how to use it with php. I've been reading a bit about Zend AMF but still can't really understand why it's needed over just sending the variables to the mysql via php using POST or GET. My main concerns are security and ease of setup in the code.
    FlashGameMaker.com - er..where I say stuff.

  8. #8
    Funkalicious TOdorus's Avatar
    Join Date
    Nov 2006
    Location
    Nijmegen, Netherlands
    Posts
    697
    My experience is with BlazeDS (java backend) , so this may not apply to PHP.

    In your case AMF wouldn't win you much, as the server would deserialize it into some sort of collection. You would then store the deserialized data in your database. It's probably best to use a custom map object and cobvert it into a Bytearray. Send the Binary data of the Bytearray straight into the database.

    When you retrieve it you can use registerclassAlias to convert the ByteArray back into your custom object.

  9. #9
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    I'm sorry, I didn't see any email letting me know you responded. BlazeDS and AMFPHP pretty much work the same way. AMFPHP serializes the data in AMF and sends it back from the server just like BlazeDS does. The advantage over using POST is that, generally, you don't have to write as much code.

    If you post data to php then you have to write all of those $_POST variable declarations, then put the data into the database; and if you're returning anything you then will likely either echo a url encoded string or some xml. Then, when you get that back from flash you have to parse the xml or go through the string.

    When you use AMFPHP you can send an array, or any variable, to a php function or class, grab it in php like you would any parameter in a function or method, insert it into a database, and then simply return any data back like an array, string, number, object, whatever. Once it's back in flash it simply holds it's datatype as an object, string, number, array or whatever. There's usually less code to write on both sides because AMFPHP, or BlazeDS for that matter, is doing all of the parsing/encoding for you. As for security either is as secure, or insecure, as you make them. AMFPHP has authentication rules and BlazeDS has their security restraint roles as well. Either, like Post or Get will work over ssl too.

    In short, it's typically a faster development environment using these third party tools. Zend AMF works well too although I still prefer AMFPHP because of its footprint. Don't quote me on that as I haven't compared either in over 2 years so that may have changed!
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center