Previous Blog Next Blog
Prev/Next Blog
by date

Save, Load, and Pause (oh my!)

Save, Load, and Pause (oh my!)
Name:Corey Punches
Date Posted:Jun 11, 2007
Rating:Not Rated
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Corey Punches

Blog post
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.

Recent Blog Posts
List:06/11/07 - Save, Load, and Pause (oh my!)
04/09/07 - Reflecting on Reflection

Submit ResourceSubmit your own resources!

Michael Perry   (Jun 11, 2007 at 12:43 GMT)
Good work so far Corey!

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.

Phil Carlisle   (Jun 11, 2007 at 12:58 GMT)
You also need to store the velocity of each object etc. Basically, anything that needs integrating/updating or restoring.

Corey Punches   (Jun 11, 2007 at 14:19 GMT)
@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!

wingman   (Jun 12, 2007 at 00:13 GMT)
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.

You must be a member and be logged in to either append comments or rate this resource.