Page 1 of 1

Save Game

PostPosted: Mon Nov 08, 2010 6:57 am
by Behdadsoft
Hi.

I made space invaders and want add auto save for game. Every step means starting a save is automatically created.
I also made a menu and I want every time players of the game came out and wanted to re-enter the game click on the game loaded, the game continues to run.
I do not know programming if you please help me.

THANKS A LOT

Re: Save Game

PostPosted: Mon Nov 08, 2010 7:46 am
by skydereign
You'll need to explain a little more. What triggers the autosave? Every time you move to the next wave the game saves, or perhaps a timer? Also how do the levels start? The mechanics for the autosave feature would be similar to that of any save system. You'll need to specify what needs to be saved. If you can give me more of an idea on how your game runs, I can help.

Re: Save Game

PostPosted: Mon Nov 08, 2010 11:41 am
by Behdadsoft
Thanks for Reply

This game is such that the loss of all enemies goes to the next step.
I like when the stage began, life, Score and the stage is running (for example: Step 2). Be saved at that moment.
And when the players disappeared and was going to play the same stage starts by clicking on the game load game menu, the same stage with all the values to be implemented by Save.

This is a Picture my Game

Image

Re: Save Game

PostPosted: Mon Nov 08, 2010 9:57 pm
by skydereign
Here is a quick example of what you want to do. The points to note are the calls to saveVars, and loadVars. Each time you defeat all the enemies in the wave, it calls the nextWave function in global code.
Code: Select all
void
nextWave()
{
    int i;
    int j;
    for(i=0;i<6;i++)
    {
      for(j=0;j<level+1;j++)
      {
        CreateActor("enemShips", "icon", "(none)", "(none)", view.x+120+i*60, view.y+120+j*20, true);
      }
    }
    saveVars("save","save");
}


The call to saveVars will only happen each time you go to the next level and it will save the amount of lives you have, health, your score, and what level you are on. Now to load a game, you would use the code in the create actor event of the view.
Code: Select all
loadVars("save","save");
nextWave();


If you want the player to be able to select load game from a menu, you would move the loadVars to that, and trigger the new wave of enemies. Essentially this is just the normal method of saving, except you automate the process instead of having the player click a save button.

Re: Save Game

PostPosted: Tue Nov 16, 2010 10:26 am
by Behdadsoft
Thank you.

But my game stages are separate and I do not know how should I use this code.

Re: Save Game

PostPosted: Wed Nov 17, 2010 8:19 am
by skydereign
If they are separate that actually makes it easier. As long as in the view's create actor event, you insert the loadVars code, and upon level completion (when you move to the next ged), put the saveVars. The autosave is just you putting in the saveVars code in the event that ends the level. An example would be putting it into the DestroyActor of the enemy actor type.
Enemy -> Destroy Actor -> Script Editor
Code: Select all
if(ActorCount("Enemy")==1) // event actor is the last enemy
{
    saveVars("savegroup", "savegroup");
    LoadGame("game.ged");
}

Re: Save Game

PostPosted: Wed Nov 17, 2010 7:16 pm
by Behdadsoft
Thank you.
I know how to go one stage to another stage. I wonder how, after being destroyed, again via the menu can be loaded from the same stage of game play continues.

Re: Save Game

PostPosted: Wed Nov 17, 2010 9:05 pm
by skydereign
What you would need is a level variable added to the save group. So when you click to play the game, you would loadVars, and then depending on the level, load game.
Code: Select all
loadVars("savegroup","savegroup");
switch(level) // level is a variable in savegroup
{
    case 0:
    LoadGame("level0.ged");
    break;

    case 1:
    LoadGame("level1.ged");
    break;
   
    // etc
}


And when you complete a level, make sure to increase the level variable, and then saveVars.

Re: Save Game

PostPosted: Sat Nov 20, 2010 12:30 pm
by Behdadsoft
Hello. Thank you for your help

I am a little confused, if possible, more about this script further explain or leave me a sample.

THANKS A LOT

Re: Save Game

PostPosted: Sat Nov 20, 2010 12:45 pm
by schnellboot
you have used the sprites from 1945?

Re: Save Game

PostPosted: Sat Nov 20, 2010 3:12 pm
by Behdadsoft
What?