A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: best way to store 'ghost racer' data

  1. #1
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149

    best way to store 'ghost racer' data

    Has anyone had to come up against the need to store in a database a large array of data. Im recording lap data for ghost riders, and the resulting textfiles as pure array data are 60-100k (thats a sample every 100 - 200 ms)

    I am thinking that Ill take this data array and maybe use a byteArray compression on it and then whack it into my mysql database as binary data.
    But I havent the foggiest as to how to go about it.....

    Any suggestions on a best practice for this most gratefully accepted
    Last edited by Flashkit; 08-15-2008 at 02:40 AM.
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  2. #2
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    With some in depth googling I have found this to try.....

    http://www.sephiroth.it/phpwiki/inde...earray_as_Blob
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  3. #3
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    I dunno if that link's sorted your problems or not mate.

    Failing that, Run Length Encoding could save a lot ( You may have to split the data up into different streams, so say the speed in one stream which may compress well, and the "movement", ie rotation, in another. For the rotation delta encoding may be better, so you just save the differences, ie <timestamp><change in degrees>, although RLE would be sucky on that, hence the two streams ).

    Also how about the storing the data in a bitmap, and letting a png encoder pack it all down for you ?

    Squize.

  4. #4
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    if the user can't interact with the ghost and the simulation is tied to the framerate, you can just store input changes and the frame at which they occur instead of sampling repeatedly.

  5. #5
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    maybe check the angle from the last capture position to the current one and if it is equal or within a smal rangle like say 2° or 3° skip it and dont save it. But that way you would also have to store the timestamp or some skip number with each position or skip.

    Binary data is indeed the way to go,- even reading will be very easy
    it might something look like this:
    PHP Code:
    var binaryData:ByteArray = ... // data loaded externally into a byte array

    var length binaryData.readShort();

    var 
    x:int,y:int,time:int;
    for(var 
    i:int 0lengthi++) {
        
    =        binaryData.readShort();
        
    =        binaryData.readShort();
        
    time =     binaryData.readShort();

    writing in AS3 might be something like:
    PHP Code:
    var binaryData:ByteArray = new ByteArray();
    binaryData.writeShort(ghosting.length);//array length

    for(var i:int 0lengthi++) {
        
    binaryData.writeShort(ghosting[i].x);
        
    binaryData.writeShort(ghosting[i].y);
        
    binaryData.writeShort(ghosting[i].time);

    look up the "ByteArray" class in the CS3 help (or online) because for example writeShort and writeInt are not the same (16 vs 32 bit)

    some as3 binary links:
    http://mikegrundvig.blogspot.com/200...ta-in-as3.html
    http://www.kaourantin.net/2005/10/pn...er-in-as3.html

  6. #6
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    I would give each arrow key its own binary stream, and use RLE to compress them. Simple, accurate, and small.
    http://www.birchlabs.co.uk/
    You know you want to.

  7. #7
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    I am using a bytearray indeed with the writeshorts.
    I had hoped to use amfphp to save them as blobs in a mysql database, but no matter what I tried it borked, so I make a bytearray, compress it and then turn it into a base64 string.

    All up it takes a 60k file down to 1k which is pretty sweet.
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

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