Bithack / principia

Open source physics-based sandbox game.
https://principia-web.se
Other
260 stars 25 forks source link

Undo functionality #139

Open rollerozxa opened 9 months ago

griffi-gh commented 6 months ago

how should we approach this?

intermediate saves is probably the easiest approach to implement.
i.e. we could just create a full level save (in-memory or as temporary files) before each action and restore them on ctrl-z. The game already has mechanisms to quickly and seamlessly reload saves with basically no side effects.

we can also do it by storing just the positions and properties of objects and restoring them;
this requires more integration within the game to make it undo-aware.

should we also support redo?

rollerozxa commented 6 months ago

Well the former sounds easier, as long as we've got memory to spare (we don't have as many low-mem mobile devices we need to support nowadays like there was in 2013). Having to save an entire level file in memory (zlib compression and level thumbnail and all) for each change sounds excessive, so some sort of intermediary that faster to save and preferrably memory efficient. (store delta encoded differences of the level buffer? I dunno)