[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] ideas for saving points in games



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

kschnee@xxxxxxxxxx wrote:
> If you want to store a dictionary, a quick way to do that is to use text,
> writing a key:value pair to each line and ignoring lines that start with
> "#".

If we're just talking about our favorite serialization format, I much
prefer YAML. It's clear, it's human-readable, it's recursive and so
very powerful, and the code to parse it is there already. The only
annoying part is that tuples get stored in a funky way, with strings
like "!!python/tuple". Converting to lists works but is kind of
annoying. Of course, it's just a cosmetic feature, so whatever.

Depending on how you structure your game, saving can be more or less
difficult. In an RPG, for instance, saving state is probably just a
matter of saving your current location, saving whatever "flags" have
been set in the game so far, and saving your current party's
attributes (health, etc.). But if your level system isn't based on
flags, then it can be more complicated. For instance, if I were
implementing an RPG, I'd probably implement quests as Python scripts,
like this:

killed(Dragon)
visited("village1")
talked("village1", "elder")
choice = talked("village1", "leader") # let the player choose victim
if choice == 1:
  killed(Ogre)
else:
  killed(Troll)

It's not such a good fit here, but having a Python-based level format
is one of the tricks I'm very fond of. In this case, saving state
would require saving the execution state of the level, and
reconstructing it on load, and I'm not entirely sure how to do that in
the general case. I've been a little leery of implementing save states
in my game for just this reason, but it's probably doable with enough
work.

Another question is, what if things change in your source code? Maybe
a flag that was called "flag1" is now called "village1flag". Is there
an organized way to keep track of the changes to your level format and
deal with the changes automatically (so when you get an old save that
says "flag1", you automatically convert it to "village1flag")?

Ethan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+I9thRlgoLPrRPwRApQuAJ9jchYudfvz7A4hvAYZ8cqZ02ZywACfRf/2
aO50XuOCfpOjet35WiwQl2o=
=J/1O
-----END PGP SIGNATURE-----