02-12-2013, 04:31 AM
(This post was last modified: 02-12-2013, 04:37 AM by Bombshell93.)
I'd be against serializing, it doesn't really gain you anything, in fact it inflates file size in XML's Case,
Just use BinaryReader and BinaryWriter (System.IO)
there simple as can be so long as you dont get lost between your saving and loading loops (which I did at one point, it leads to the loading desynchronising with the file and reading stuff wrong, but it'll only happen in complex loops, in my case I was saving Tilesets from a SpatialHashTable)
the original reason I wasn't using serializers is because their not supported on xbox and windows phone, I THINK but not sure, I think its not available on the reach profile, which if you dont use the reach profile your game wont run on DX9 systems only DX10+, I realised this a while ago when I gave a game to my friend with a really crappy laptop.
EDIT:
look up Spatial Hash Table its much nicer than a quadtree for non-cluttered collisions (quadtrees are meant for masses of colliders, the overhead isn't worth it in this case)
I just made a fer helper methods to handle the SpatialHashMap with Rectangles as well as Vector2's this meant I could just pass the objects area and add it into each grid piece, or get all the objects in a grid within an area (excluding duplicates ofc) it takes a bit of cleaning up but its really fast and really simple.
my trick was to each frame get a list of the objects within the cells which intersected with the view, and only pay attention to those object, things outside of that list wouldn't even get a check against them, no need, already have a list of all the relevant items.
Just use BinaryReader and BinaryWriter (System.IO)
there simple as can be so long as you dont get lost between your saving and loading loops (which I did at one point, it leads to the loading desynchronising with the file and reading stuff wrong, but it'll only happen in complex loops, in my case I was saving Tilesets from a SpatialHashTable)
the original reason I wasn't using serializers is because their not supported on xbox and windows phone, I THINK but not sure, I think its not available on the reach profile, which if you dont use the reach profile your game wont run on DX9 systems only DX10+, I realised this a while ago when I gave a game to my friend with a really crappy laptop.
EDIT:
look up Spatial Hash Table its much nicer than a quadtree for non-cluttered collisions (quadtrees are meant for masses of colliders, the overhead isn't worth it in this case)
I just made a fer helper methods to handle the SpatialHashMap with Rectangles as well as Vector2's this meant I could just pass the objects area and add it into each grid piece, or get all the objects in a grid within an area (excluding duplicates ofc) it takes a bit of cleaning up but its really fast and really simple.
my trick was to each frame get a list of the objects within the cells which intersected with the view, and only pay attention to those object, things outside of that list wouldn't even get a check against them, no need, already have a list of all the relevant items.