Need Save load help still.

Game Engine, Players & Web Plug-in, Virtual Reality, support for other engines

Moderators: jesterKing, stiv

Jedijds
Posts: 126
Joined: Mon Jan 30, 2012 5:19 am

Need Save load help still.

Postby Jedijds » Wed Mar 14, 2012 5:42 pm

How do I make a button that I can press and it will save where every thing is in the game? If I leave then come back or die in the game I would like a button I can then press that I can load the game I saved before. If any one knows how could you make a tutorial on YouTube?
۞◄█°‖‖‖‖‖█ʭʭ╬(░▒▓▓▒▒▒▒▒▒▒▒▒)

przemekk
Posts: 9
Joined: Tue Jan 25, 2011 9:08 am

Re: Need Save load help still.

Postby przemekk » Wed Apr 04, 2012 11:33 pm

Jedijds wrote:How do I make a button that I can press and it will save where every thing is in the game? If I leave then come back or die in the game I would like a button I can then press that I can load the game I saved before. If any one knows how could you make a tutorial on YouTube?


You can iterate through all object in the scene and save the objects position, rotation in a text file.
Then when you back to the game you can load the file from disk and restore the objects rotation and position.

i.e.: (this is a pseudo code - not the real one. You have to design storing in files by yourself)

Code: Select all

def save():
    import GameLogic
    scn = GameLogic.getCurrentScene()
    for obj in scn.objects:
         #save to file obj.name
         # save to file obj.position,
         # save to file obj.rotation

dev load():
    import GameLogic
    scn = GameLogic.getCurrentScene()
   
    #open the file and load data into list
    for item in list:
        scn.objects[item.name].position = item.position
        scn.objects[item.name].rotation = item.rotation



Return to “Interactive 3d”

Who is online

Users browsing this forum: No registered users and 0 guests