Save, Load, and Pause (oh my!)
by Corey Punches · 06/11/2007 (5:35 am) · 5 comments
I've been working on a single/two-player coop type RPG-adventure game. One of the "musts", in my opinion, for this type of game is the ability to save and load games whenever the player wants. With that in mind I designed the persistance layer of my game in a way that I hope will allow me to do this.
The persistance layer was constructed by utililizing SQLite as a DB manager and creating database objects to keep track of inventory, equipment, items, quests, skills, etc. Saving the game creates a set of tables containing the rows of all the current "working" tables. Loading simply truncates the working tables and inserts from the appropriate save game tables.
I've run into an issue however in regards to saving the actual Player and NPC objects. During a save I create a copy of a world objects table which contains object id, name, current position, and transform. I limit the objects to those that are only in "view" of the current player objects.
Here's my problem, when I begin the save process the world is still in "motion", meaning that NPC's are still travelling along their paths, projectiles are still in flight, etc. During load (and I haven't tried this yet) I assume I can apply the last transform to the saved objects and set them back into motion. I hope.
TGB has a pause function that pauses the current sceneobject (IIRC). Is there any way to pause the simulation in TGE? Maybe it's not important, but I'd really like the world to pause when I popup the save/load GUI.
When, and/or if, I get this working the way I'd like I'll try to create a resource as I think this might help quite a few people.
The persistance layer was constructed by utililizing SQLite as a DB manager and creating database objects to keep track of inventory, equipment, items, quests, skills, etc. Saving the game creates a set of tables containing the rows of all the current "working" tables. Loading simply truncates the working tables and inserts from the appropriate save game tables.
I've run into an issue however in regards to saving the actual Player and NPC objects. During a save I create a copy of a world objects table which contains object id, name, current position, and transform. I limit the objects to those that are only in "view" of the current player objects.
Here's my problem, when I begin the save process the world is still in "motion", meaning that NPC's are still travelling along their paths, projectiles are still in flight, etc. During load (and I haven't tried this yet) I assume I can apply the last transform to the saved objects and set them back into motion. I hope.
TGB has a pause function that pauses the current sceneobject (IIRC). Is there any way to pause the simulation in TGE? Maybe it's not important, but I'd really like the world to pause when I popup the save/load GUI.
When, and/or if, I get this working the way I'd like I'll try to create a resource as I think this might help quite a few people.
About the author
#2
06/11/2007 (5:58 am)
You also need to store the velocity of each object etc. Basically, anything that needs integrating/updating or restoring.
#3
So, if I understand you correctly, there is a global $timeScale, that if I set it to 0 the whole sim is paused? That's great!
@Phil,
Yes, you're correct, I'm also going to store the velocity of the objects. If I do that and reapply those values when I load do you think they will be restored in motion?
Thanks for the comments!
06/11/2007 (7:19 am)
@Michael,So, if I understand you correctly, there is a global $timeScale, that if I set it to 0 the whole sim is paused? That's great!
@Phil,
Yes, you're correct, I'm also going to store the velocity of the objects. If I do that and reapply those values when I load do you think they will be restored in motion?
Thanks for the comments!
#4
06/11/2007 (5:13 pm)
Yes, you can use $timeScale = 0; to pause the simulation. Careful on your gui work though. If you use schedules to push/pop guis, they will not work without a little engine work.
#5
08/09/2008 (4:32 pm)
Did you ever get this made and into a resource? Looking for a save/load system for my FPS game, Thanks 
Community Manager Michael Perry
ZombieShortbus
Since you asked, I might as well answer: Since TGB is Torque Technology, I have to assume it has the beautiful global variable, $timeScale. In all the other engines, if you set this to 0, the whole sim will pause.
Looking forward to seeing the resource when it comes out.