Re: what do i need in an rpg engine?

@17
You want to google game serialization.  That's the magic phrase.

The really basic version is you import json, you convert everything to a dict of dicts/whatever, you json.dump it to a file.

The less basic version I did was: objects register what properties they have on them, the types of those properties, and the kinds of children they can have.  So for example (and with some work this can be valid Python, but this is some work by my standards, not yours):

class Player(Serializable):
    x = double_property()
    y = double_property()
    health = double_property(default = 100)
    inventory = relationship(many = true)
    weapon = relationship()

Etc.  Then your serializer can be entirely generic, consume the metadata from the object type in question, and walk the graph, converting any relationship to a list of ids and serializing every object as a blob of json.

And why do I say it's easy to go overboard...well, once you have that you can save the game at any instant in time and reload it to exactly the same state, and it's tempting to just do that as the player's save file, but at some point you have to write scripts to migrate the save file forward when the version of the game changes and your life is impossibly difficult if that script has to act on the whole world, rather than just a tiny bit of the world that happens to be in the player's save file.

For things like quest flags etc, you just extend this with either support for Python dicts and lists (a json_pproperty type) or you let classes override the automatic serialization.

My next project after Synthizer is done enough that I'm not getting it to some basic level of usableness was going to be physics, but perhaps I'll take a Saturday and write this for everyone because it's not that hard if you know how Python metaclasses work, and somehow no one else has written it for Python (though there are C++ versions to one degree or another).  All of Python serialization either doesn't actually finish it (it's up to you to walk the graph) or comes with a lot of overhead that you don't want in there for games (every ORM ever).



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Hektor via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to