Saving level progress

Game Editor comments and discussion.

Saving level progress

Postby Leeesaw » Thu Oct 07, 2010 4:05 pm

Thank you all so much for your help with my many questions! Soon I will have a demo to show for all this pestering.

Ok so im making an exploration platformer... and i want it to work on all platforms (but mostly iphone). The iphone cant seem to handle my huuuuge map... so i decided to make seperate level files rather than warp my player around a huge map...

However, because its an exploration game and not a linear platformer... I need to save the progress made in in level. I figured out how to save my score and my objects collected (Thank you Bee-Ant for your tutorial)... but i need to also save the actors destroyed, so that when the player returns to the level, everything they have collected (treasure chests they have opened) dont reset.

The only way I can think of doing this is creating a saved variable (like we are doing with the score) for each individual intractable object (every single gem). This would be very tedious. Is there a better way?
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby SirAz » Fri Oct 15, 2010 8:55 am

Yeah. What I'm doing is using a variable as a 10x10 array, with each NPC, event and object stored as a binary (e.g. 0 is available, 1 is used up/killed/opened). You can make your array bigger, have the first number as level and the 2nd as the item or creature within the level ([1],[2] is the second creature on the first level). When creating creatures, make them check the variable on the create actor event. If they come up a 1, have them destroyed, or simply not appear.

Anyway, sorry for the long reply wait. I'm still pretty new here myself.
User avatar
SirAz
 
Posts: 23
Joined: Fri Oct 01, 2010 10:47 pm
Location: United Kingdom
Score: 2 Give a positive score

Re: Saving level progress

Postby Bee-Ant » Fri Oct 15, 2010 9:10 am

Leeesaw wrote:but i need to also save the actors destroyed, so that when the player returns to the level, everything they have collected (treasure chests they have opened) dont reset

This is kinda complex...
Use some arrays to store all the states.
If you're interested I will make some demo
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Saving level progress

Postby Leeesaw » Fri Oct 15, 2010 6:05 pm

Thanks for the help. I am using saveVars for now to save variables for all my keys and chests... later on i will hopefully put these into arrays.

So my new problem is severe lag when I test on the iPhone. The first time I tested using seperate files on iPhone worked great. But this time its really laggy. The file sizes arent very big at all yet (68 kb and 78 kb for GED) (700 kb and 570 kb for exported .dat files)

I am wondering if something I am coding is causing some lag. Perhaps since I moved alot of my character movement code to the character draw actor.
Code: Select all
//Slow Fall
if (slowFall ==1)
{yvelocity =  2.5;
canjump =0;

if (faceLeft ==1)

{ChangeAnimation("Event Actor", "Jump_left", FORWARD);}
else
{ChangeAnimation("Event Actor", "Jump_right", FORWARD);}
}

//Gravity
if (yvelocity<10)
{yvelocity = yvelocity + 0.7;}

if (yvelocity<20)
{yvelocity = yvelocity + 0.3;}

//Walking
if (goRight ==1)
{
x= x + 10;
faceLeft =0;
if (slowFall==0 || oG==1 || oG2==1 || oG3==1 || oG4==1 && yvelocity>1)
{ChangeAnimation("Player", "Walk_Right", FORWARD);}

}

if (goLeft ==1)
{
x= x - 10;
faceLeft =1;
if (slowFall==0 || oG==1 || oG2==1 || oG3==1 || oG4==1 && yvelocity>1)
{ChangeAnimation("Player", "Walk_Left", FORWARD);}

}

//Jumping
if(AButtonPress==1 && canjump>0)
{
    yvelocity= yvelocity -14;
    canjump--;
 
    if (faceLeft ==1)
    {ChangeAnimation("Event Actor", "Jump_left", FORWARD);}
    else
    {ChangeAnimation("Event Actor", "Jump_right", FORWARD);}
    }

if (AButtonPress ==1)
{
if (yvelocity >= 2.5)
{
slowFall =1;

}
}

//Idle
if (AButtonPress ==0 && goRight ==0 && goLeft==0)
{
    if (faceLeft ==1)
    {ChangeAnimation("Event Actor", "Idle_left", FORWARD);}
    else
    {ChangeAnimation("Event Actor", "Idle_right", FORWARD);}
     slowFall=0;
    }
 
//Death
if (playerDeath ==1)
 {

    if(fadeBlack.transp>0)
{
    fadeBlack.transp-=0.08;
}

}

    if(fadeBlack.transp<=0)
    {
        playerDeath =0;
        if (startLocation ==0)
               { MoveTo("Player", 0.000000, 0.000000, 100000.000000, "startLocation0", "");}
        if (startLocation ==1)
               { MoveTo("Player", 0.000000, 0.000000, 100000.000000, "startLocation1", "");}
        if (startLocation ==2)
               { MoveTo("Player", 0.000000, 0.000000, 100000.000000, "startLocation2", "");}
        if (startLocation ==3)
               { MoveTo("Player", 0.000000, 0.000000, 100000.000000, "startLocation3", "");}
        if (startLocation ==4)
               { MoveTo("Player", 0.000000, 0.000000, 100000.000000, "startLocation4", "");}
 
    }

 
  if (playerDeath ==0)
  {
  if(fadeBlack.transp<1)
 
  { fadeBlack.transp+=0.08;
}
 }
 
 
 if (playerFaint ==1)
{  startLocation =0;
   saveVars ("data.sav", "data");
   LoadGame("AngerTower");
   playerFaint =0; }
 



And along with that I have dialog information stored in the draw actors of other characters.

Its either that or the lag is happening due to my .sav files now. Those are the two big changes I made.

No lag in the Game Mode in the editor. Please If anyone has any idea of what It could be, I would really appreciate the help!
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby TSO » Fri Oct 15, 2010 6:14 pm

Code: Select all
//gravity

Code more or less seems fine.
But not quite sure if code under gravity makes sense.
A lot of the rest of it is in short form so Idk if there is a specific point where you got a loop doing nothing and simply taking up resources to be rechecked.

Also if you have a lot of dialog under draw actor. Perhaps even though it's not being called up right away. It drags on the iPhone 'cpu' time to read through it onto the next piece of code.

Those would be most likely sources or areas of lag I'd guess.
TSO
 
Posts: 87
Joined: Thu Sep 02, 2010 5:53 pm
Score: 4 Give a positive score

Re: Saving level progress

Postby Leeesaw » Fri Oct 15, 2010 6:17 pm

If I want to move it out of the draw actor...
Where can I place code that is being triggered only by a variable?
or
How do I keep my code from constantly checking the variables?
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby Leeesaw » Fri Oct 15, 2010 6:22 pm

But not quite sure if code under gravity makes sense.


It works exactly how I want it to in my game. :D
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby TSO » Fri Oct 15, 2010 6:27 pm

Perhaps you can stick your dialog in save variables?
An array may help keep track by having a number for a character and a number for which dialog to use?
Then use the two numbers perhaps to load specific dialog?
if you can cut the dialog. export and test run to see if it works?

I'm thinking maybe it's not so much as checking variables as having to much at one time in one place I think...
I don't use an Iphone and from it's rather odd specs I can't see it processing anything to big. It's got plenty of storage space but doesn't seem to great at processing a lot.
TSO
 
Posts: 87
Joined: Thu Sep 02, 2010 5:53 pm
Score: 4 Give a positive score

Re: Saving level progress

Postby Leeesaw » Fri Oct 15, 2010 6:46 pm

Im not sure how I would exactly make that work.
Here is how I am running my dialog right now:
On Mouse Button Down of Text Box:
Code: Select all
nextDialog =1;


On Mouse Button Down of Veronica:
Code: Select all
if(talkVeronica == 0)
{
     strcpy(dialog_text.text, "Hello?");
     ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
     dialog =1;
     talkVeronica = 1;
     nextDialog=0;
}

if(talkVeronica == 7)
{
     strcpy(dialog_text.text, "Sorry, I don't mean to be rude...\nbut have they told you why\nyou are here?");
     ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
     dialog =1;
     talkVeronica = 8;
     nextDialog =0;
}

if(talkVeronica == 14)
{
     strcpy(dialog_text.text, "You seem pretty ok with the\ncurrent situation.");
     ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
     dialog=1;
     talkVeronica = 15;
     nextDialog =0;
}



Draw Actor Veronica:

Code: Select all
if(talkVeronica == 1 && nextDialog==1)
{
     strcpy(dialog_text.text, "Oh... Hello.\nWhat are you doing here? Are you\na princess?");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     talkVeronica = 2;
     nextDialog =0;
}

if(talkVeronica == 2 && nextDialog==1)
{
     strcpy(dialog_text.text, "Of course I'm a Princess!!!");
     ChangeAnimation("dialog_image", "dialog_ardynAngry", FORWARD);
     dialog =1;
     talkVeronica = 3;
     nextDialog =0;
}

if(talkVeronica == 3 && nextDialog==1)
{
     strcpy(dialog_text.text, "Erm... sorry. I am Princess Ardyn.\nPleased to make your aquaintence.");
     ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
     dialog =1;
     talkVeronica = 4;
     nextDialog =0;
}

if(talkVeronica == 4 && nextDialog==1)
{
     strcpy(dialog_text.text, "You don't recognize me? I am Princess\nVeronica. Fairest in the land...");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     dialog =2;
     talkVeronica = 5;
     nextDialog =0;
}

if(talkVeronica == 5 && nextDialog==1)
{
 
     strcpy(dialog_text.text, "Um......kay.");
     ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
     talkVeronica = 6;
     nextDialog =0;
 
}
if (talkVeronica == 6 && nextDialog==1)
{
   dialog =0;
   talkVeronica =7;
}

if(talkVeronica == 8 && nextDialog==1)
{
     strcpy(dialog_text.text, "You know how these villians are...\nThey all want a lovely princess to marry.");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     talkVeronica = 9;
     nextDialog =0;
}

if(talkVeronica == 9 && nextDialog==1)
{
     strcpy(dialog_text.text, "And you were probably kidnapped to\nbe a bridesmaid.");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     talkVeronica = 10;
     nextDialog =0;
}

if(talkVeronica == 10 && nextDialog==1)
{
     strcpy(dialog_text.text, "Hmm... a bridesmaid? It doesn't\nquite fit...");
     ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
     talkVeronica = 11;
     nextDialog =0;
}

if(talkVeronica == 11 && nextDialog==1)
   {
     strcpy(dialog_text.text, "Say, it's rather stuffy in here. If it's\nnot too much trouble...");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     talkVeronica = 12;
     nextDialog =0;
   }
 
if(talkVeronica == 12 && nextDialog==1)
{
     strcpy(dialog_text.text, "Could you take this key and\nunlock that upper window?");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     talkVeronica = 13;
     nextDialog =0;
}


if(talkVeronica == 13 && nextDialog==1)
{
     dialog =0;
     talkVeronica = 14;
     nextDialog =0;
}

if(talkVeronica == 15  && nextDialog==1)
{
     strcpy(dialog_text.text, "Ha ha ha... It's because I'll be\nrescued just in time by a handsome\nknight. They are so cute!");
     ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
     talkVeronica = 13;
     nextDialog =0;
}


If someone knows an easier way/ better way of doing this I would appreciate it. The only thing I really know how to work properly is If statements.
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby DarkParadox » Fri Oct 15, 2010 7:12 pm

I did a quick run through of "Veronica"'s code, and did some optimizing. [untested... tell me if it doesn't work]


Draw Actor:
Code: Select all
if(nextDialog == 1)
{
    switch(talkVeronica)
    {
        case 1:
        strcpy(dialog_text.text, "Oh... Hello.\nWhat are you doing here? Are you\na princess?");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
        case 2:
        strcpy(dialog_text.text, "Of course I'm a Princess!!!");
        ChangeAnimation("dialog_image", "dialog_ardynAngry", FORWARD);
        break;
       
        case 3:
        strcpy(dialog_text.text, "Erm... sorry. I am Princess Ardyn.\nPleased to make your aquaintence.");
        ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
        break;
       
        case 4:
        strcpy(dialog_text.text, "You don't recognize me? I am Princess\nVeronica. Fairest in the land...");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
        case 5:
        strcpy(dialog_text.text, "Um......kay.");
        ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
        break;
       
        case 6:
        dialog = 0;
        break;
       
        case 8:
        strcpy(dialog_text.text, "You know how these villians are...\nThey all want a lovely princess to marry.");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
        case 9:
        trcpy(dialog_text.text, "And you were probably kidnapped to\nbe a bridesmaid.");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
        case 10:
        strcpy(dialog_text.text, "Hmm... a bridesmaid? It doesn't\nquite fit...");
        ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
        break;
       
        case 11:
        strcpy(dialog_text.text, "Say, it's rather stuffy in here. If it's\nnot too much trouble...");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
        case 12:
        strcpy(dialog_text.text, "Could you take this key and\nunlock that upper window?");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
        case 13:
        dialog =0;
        break;
       
        case 14:
        trcpy(dialog_text.text, "Ha ha ha... It's because I'll be\nrescued just in time by a handsome\nknight. They are so cute!");
        ChangeAnimation("dialog_image", "dialog_veronica", FORWARD);
        break;
       
    }
    talkVeronica++;
    nextDialog = 0;
}


Mouse Down:
Code: Select all
switch(talkVeronica)
{
    case 0:
    strcpy(dialog_text.text, "Hello?");
    ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
    goto GGOTO;
    break;
   
    case 7:
    strcpy(dialog_text.text, "Sorry, I don't mean to be rude...\nbut have they told you why\nyou are here?");
    ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
    goto GGOTO;
    break;
   
    case 13:
    strcpy(dialog_text.text, "You seem pretty ok with the\ncurrent situation.");
    ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
    goto GGOTO;
    break;
   
    default:
    GGOTO:
    talkVeronica++;
    nextDialog=0;
    dialog=1;
}
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Saving level progress

Postby Leeesaw » Fri Oct 15, 2010 7:21 pm

The last text box doesn't leave. Probably because I had it loop back to 13.... how can I make this work again?

Also if you click/tap on Veronica while in the dialog it jumps ahead.
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby DarkParadox » Fri Oct 15, 2010 7:26 pm

Mouse Down Edits...

Code: Select all
switch(talkVeronica)
{
    case 0:
    strcpy(dialog_text.text, "Hello?");
    ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
    goto GGOTO;
    break;
   
    case 7:
    strcpy(dialog_text.text, "Sorry, I don't mean to be rude...\nbut have they told you why\nyou are here?");
    ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
    goto GGOTO;
    break;
   
    case 14:
    strcpy(dialog_text.text, "You seem pretty ok with the\ncurrent situation.");
    ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
    goto GGOTO;
    break;
   
    case -1:
    GGOTO:
    talkVeronica++;
    nextDialog=0;
    dialog=1;
}
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Saving level progress

Postby Leeesaw » Fri Oct 15, 2010 7:37 pm

Got it all working nicely! Thanks for your help. Point for you!
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby Leeesaw » Tue Oct 19, 2010 8:20 pm

I still need to find a way to get the script in the player character's draw actor cleaner... its probably the reason my game is so laggy. The current code is posted above.
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Saving level progress

Postby sonicfire » Mon Jan 31, 2011 2:15 am

DarkParadox wrote:Mouse Down Edits...

Code: Select all
switch(talkVeronica)
{
    case 0:
    strcpy(dialog_text.text, "Hello?");
    ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
    goto GGOTO;
    break;
   
    case 7:
    strcpy(dialog_text.text, "Sorry, I don't mean to be rude...\nbut have they told you why\nyou are here?");
    ChangeAnimation("dialog_image", "dialog_ardynConfused", FORWARD);
    goto GGOTO;
    break;
   
    case 14:
    strcpy(dialog_text.text, "You seem pretty ok with the\ncurrent situation.");
    ChangeAnimation("dialog_image", "dialog_ardynHappy", FORWARD);
    goto GGOTO;
    break;
   
    case -1:
    GGOTO:
    talkVeronica++;
    nextDialog=0;
    dialog=1;
}


you can use GOTO´s in GE?? :shock:
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest