#Save game feature in C, help and advice would be appreciated

11 messages · Page 1 of 1 (latest)

tulip tangle
#

Currently making a save game feature for my 2d game made in c. currently storing my game state as json although this is feeling a bit tedious, was wondering if anyone has implemented something similar and if so what format they used to store the data (json, xml, writing a file from a struct?) Not sure what's the best approach. Any nudges in the right direction would be appreciated 🙂 happy coding guys.

exotic forgeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

rustic jungle
#

What kind of stuff are you even saving?
Data you need to save for a 2d game could go all the way from just the players x and y position to something like a 2d minecraft where you need to save every block placed/destroyed, achievements, ...

#

Also why is the JSON approach feeling tedious?

tulip tangle
#

its a deck building card game. but the cards can be augmented so I can't really just store id's for them as I also need to store the diff (upgrades on different abilities stats). The game also has an overworld part to it, like final fantasy/zelda/pokemon so theres player position, how far they are through the story where that can access on the map etc. I'm using a cJSON library and its just a lot of boiler plate just to be able to parse and create json. Just wondering if there is a convention for this. Thanks for your question

exotic forgeBOT
#

@tulip tangle Has your question been resolved? If so, run !solved :)

rustic jungle
#

Alternatively you could use a simple plain text file to store all the information, or you invent a storage system suited exactly to your needs (something like store a bunch of structs in binary, then when you need them again the conversion is rather simple (as it's already in the correct format).

#

But yeah, judging that from the outside without all that much information about the specific project I don't think one can make a general recommendation

tulip tangle
#

I'd rather stick with C, but cheers for the suggestion. Think I'll go with storing the structs in binary, ta

#

!solved