Saving place on separate ged

Non-platform specific questions.

Saving place on separate ged

Postby igamer » Sun Jan 02, 2011 8:19 pm

Ok let say i have a game that has 4 GEDs. Lets say I saved the game in the 3rd Ged file . But when I open the 1st Ged and press load , I want to open 3rd Ged or which ever Ged file I pressed save.
igamer
 
Posts: 21
Joined: Fri Dec 24, 2010 3:08 am
Score: 1 Give a positive score

Re: Saving place on separate ged

Postby skydereign » Sun Jan 02, 2011 8:25 pm

Easiest way is to have a variable in the save file telling you which game it was. You could use strings, but since you have to compare values, I'd use an int.
Code: Select all
loadVars("vars", "vars");
switch(gameNumber)
{
    case 0:
    LoadGame("game0.ged");
    break;

    case 1: // current game
    // do nothing
    break;

    case 2:
    LoadGame("game2.ged");
    break;
}


Of course that goes into the view's create. When you save, you set gameNumber equal to the game's equivalent index.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving place on separate ged

Postby hamdotkeren » Tue Jan 25, 2011 7:59 am

how when I have a game that cotains of an exe (menu) and 4 dat (4 stages) files. and I want to save my highscore at every stage. after completion I want to open the menu and see a list at each stage the number highscore in menu. can it??
hamdotkeren
 
Posts: 13
Joined: Sat Nov 13, 2010 2:10 am
Score: 0 Give a positive score

Re: Saving place on separate ged

Postby skydereign » Tue Jan 25, 2011 8:04 am

It can. You would need either savefiles for each dat, or create an array of variables holding the hiscore for each game. The array is neater, as there is only one save file, so here's how it works.

You'll be loading the variables at the beginning of each game (the exe and dat files). Each level should know which hiscore it should save into, by way of an index, or you simply telling it [0], [1], etc. Simply save the hiscore when you exit the .dat file, and you have all of the hiscores for each .dat file in your save file.

In your menu exe, it should also load the save file, and you have all the hiscores there, in the array.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving place on separate ged

Postby hamdotkeren » Tue Jan 25, 2011 8:56 am

thanks sky, I'll try it
hamdotkeren
 
Posts: 13
Joined: Sat Nov 13, 2010 2:10 am
Score: 0 Give a positive score

Re: Saving place on separate ged

Postby hamdotkeren » Fri Feb 04, 2011 2:16 pm

hi sky...
1. I have a little problem, I have a save file that contains the variable with the array 10. then on my game highscore list I made one actor to perform load, then by using 9 clone from these actors and use the "switch" function I want to do a load as well as for an array of different, but the result does not work,
this is my code
Code: Select all
switch(cloneindex)
{
case 0:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[0];
break;
case 1:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[1];
break;
case 2:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[2];
break;
case 3: loadVars("score.txt", "sorokan"); stage.textNumber=kotak[3];
break;
case 4:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[4];
break;
case 5:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[5];
break;
case 6:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[6];
break;
case 7:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[7];
break;
case 8:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[8];
break;
case 9:loadVars("score.txt", "sorokan"); stage.textNumber=kotak[9];
break;
}

kotak is array variable
stage is an actor

2. I want to make the highscore list like other games that contained the sequence name from the highest scoring player to score the lowest, number around 40 people. Can you give me directions?
hamdotkeren
 
Posts: 13
Joined: Sat Nov 13, 2010 2:10 am
Score: 0 Give a positive score

Re: Saving place on separate ged

Postby schnellboot » Fri Feb 04, 2011 8:20 pm

1. I don't see any mistakes in your code
Did you set up the stage actor correctly with font and number as text?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Saving place on separate ged

Postby hamdotkeren » Sun Feb 06, 2011 1:49 pm

this is my file, if I use 10 actors, then the load function can work but why when using an actor and 9 clone, then the load function does not work,

please help
Attachments
New Folder.rar
(37.76 KiB) Downloaded 61 times
hamdotkeren
 
Posts: 13
Joined: Sat Nov 13, 2010 2:10 am
Score: 0 Give a positive score

Re: Saving place on separate ged

Postby schnellboot » Sun Feb 06, 2011 7:33 pm

Delete everything in Draw Actor of "stage" and write this
Code: Select all
Actor *get;
char str[32];
sprintf(str,"stage.%i",cloneindex);
get=getclone(str); get->textNumber=kotak[cloneindex];

code by Bee-Ant

And you can delete every loadVars function in you code and write in once in Create Actor of view actor.
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Saving place on separate ged

Postby hamdotkeren » Sun Feb 06, 2011 11:46 pm

thank you very much,
the code has worked, can you explain how this code work?

and can you give directions to my question number 2?
hamdotkeren
 
Posts: 13
Joined: Sat Nov 13, 2010 2:10 am
Score: 0 Give a positive score

Re: Saving place on separate ged

Postby schnellboot » Sun Feb 06, 2011 11:53 pm

1. Sorry ask Bee how it works xD
2. I'm sorry I don't know
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Saving place on separate ged

Postby skydereign » Sun Feb 06, 2011 11:59 pm

Code: Select all
Actor *get;
// An Actor* is essentially a way of accessing an actor (Actor pointer)

char str[32];
// make a char array to hold the clonename (used by getclone)

sprintf(str,"stage.%i",cloneindex);
// set the char array equal to the clonename of the corresponding stage actor
// so, str = stage.cloneindex

get=getclone(str);
// set the Actor * get to the actor stage.cloneindex

get->textNumber=kotak[cloneindex];
// this is how you use an Actor *
// get->textNumber gives you the actor's textNumber


Concerning your other question, have you looked at Bee-Ant's Sort function? That should work for your hiscore mechanism.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving place on separate ged

Postby hamdotkeren » Mon Feb 07, 2011 1:25 am

2 schnellboot: ok, never mind, thank's 4 your help

2 sky: thank you,
hamdotkeren
 
Posts: 13
Joined: Sat Nov 13, 2010 2:10 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest