Saving clones XY postions

Non-platform specific questions.

Saving clones XY postions

Postby Rux » Thu Apr 09, 2009 12:45 am

I'm making a game where, you have to press a button to place something. But I want to be able to save the X Y positions of all the placed objects, a specified number in a text box, a velocity in a text box, the name in a textbox, and an audio file path in a textbox. I want to save all those. How can I save variables and text into one file? Also how do you load the data, place the cloned notes in the same postions, play the audio (OGG) file path, set the specified number to a string, and move an object up in the saved velocity? I know it seems like a lot but I really need help to all those who are good at saving things. :(
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Saving clones XY postions

Postby skydereign » Thu Apr 09, 2009 1:17 am

Well, you could save each of these into individual files, if they are separate. Or save all into one. Here is an example, I can get more specific if need be. It only shows how to save the xy of actors, limited if you don't know how to make a dynamic array, and save char*s.
Code: Select all
void
varLoad (void)
{
  int actorNum;
  FILE * VARS = fopen("gameVars", "r");
  fscanf(VARS, "%d,/n", &actorNum);
  for(i=0; i<actorNum, i++)
  {
     fscanf(VARS, %d, %d,/n", &actorX[i], &actorY[i]); // actorX/actorY would be int arrays in global code
  }
  fscanf(VARS, "%s,/n", &TEXT); // TEXT is a char*, you could also just use the text actor's text variable
  // you would repeat the above for any strings you want
  // if any of the ones I did not explain you don't know how to do, just ask
  fclose(VARS);
}

void
varSave(void)
{
  int actorNum = sizeof(actorNum)/sizeof(int);
  FILE *map = fopen("gameVars", "w");
  fprintf(VARS, %d,/n", actorNum);
  for (i=0; i<actorNum; i++)
  {
     fprintf(VARS, %d, %d,/n", actorX[i], actorY[i]);
  }
  fprintf(VARS, "%s,/n", TEXT);
  fclose(VARS);
}
Last edited by skydereign on Thu Apr 09, 2009 11:54 am, edited 3 times in total.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving clones XY postions

Postby Rux » Thu Apr 09, 2009 1:23 am

um, is this the ONLY way to do it? could my task be done with the simple saveVar, loadVar functions? Just wondering.
Last edited by Rux on Thu Apr 09, 2009 1:31 am, edited 1 time in total.
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Saving clones XY postions

Postby stevenp » Thu Apr 09, 2009 1:31 am

no theres another way 1 sec, we used the same method in music box last year let me find it
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: Saving clones XY postions

Postby stevenp » Thu Apr 09, 2009 2:27 am

see DST's post a few posts down
Last edited by stevenp on Thu Apr 09, 2009 12:03 pm, edited 1 time in total.
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: Saving clones XY postions

Postby skydereign » Thu Apr 09, 2009 3:24 am

But if it is simply done with save/loadVar, then isn't it simply done? I was under the impression that with save/load vars, it was just calling the function to save a group, then load it. So it is just variable manipulation, actor count, velocity, all the things you listed. Which in some cases is easier, but the method is the same... One is applied using separate calls, the other all at once. I guess if you don't know scripting it seems a lot harder, but the idea is the same, and using your own function makes it easier to manipulate... Then again, I don't really use the save/load vars so I don't really know.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving clones XY postions

Postby Rux » Thu Apr 09, 2009 3:45 am

My main problem was how to save CLONES that were created in the game, not in GE.
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Saving clones XY postions

Postby DST » Thu Apr 09, 2009 6:32 am

It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Saving clones XY postions

Postby equinox » Thu Apr 09, 2009 10:54 am

----
Last edited by equinox on Thu Apr 09, 2009 12:14 pm, edited 2 times in total.
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Saving clones XY postions

Postby stevenp » Thu Apr 09, 2009 11:37 am

DST wrote:http://game-editor.com/forum/viewtopic.php?f=5&t=5703&hilit=+save+user+clones


thanks, i was trying to find that post, but makslane took out the " search for post" method on the website
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: Saving clones XY postions

Postby equinox » Thu Apr 09, 2009 12:13 pm

Hi at ALL,

I change the code, but not charged CHAR the data. What s wrong?

tNK1000 FOR HELP.
Attachments
FILE.rar
(103.79 KiB) Downloaded 99 times
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Saving clones XY postions

Postby skydereign » Thu Apr 09, 2009 12:15 pm

-Equinox
Change it to this, if you are using a set array some of the code is pointless, and maybe non-functioning.
-Edit, this was for your previous post
Code: Select all
int VAR[13];
char *TEXT;

void varSave(void){
  int i = 0;
   FILE *VARS = fopen("gameVars", "w");
  for (i=0; i < 13; i++)
  {
    fprintf(VARS, "%d", VAR[i]);
  }
  //  fprintf(VARS, "%s", TEXT);
  fclose(VARS);
}
void varLoad (void){
  int i = 0;
  FILE * VARS = fopen("gameVars", "r");
  for(i=0; i < 13; i++){
    fscanf(VARS, "%d", &VAR[i]);
  }
  //  fscanf(VARS, "%s", &TEXT);
  fclose(VARS);
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving clones XY postions

Postby equinox » Thu Apr 09, 2009 1:04 pm

Tnk Sky for help.

But i wish the print in this way and I can not print the CHAR:(and not all data on the same line image1)

FILE.rar
GLOBAL CODE
int VAR[4][4]; A B C
char *ICON[3][3];// OR char ICON[3][3][3]--> A = 3 ACTOR x 3 ITEM x ITEM_NAME.LEN = 3


FILE*file;// **** SAVE *******
VAR[0][0] = 111;
VAR[0][1] = 222;
VAR[0][2] = 333;

ICON[0][0] = "A";
ICON[0][1] = "B";
ICON[0][2] = "C";

file = fopen("TextNote.txt", "w");
fwrite(&VAR, sizeof(VAR), 1, file);
fwrite(&ICON, sizeof(ICON), 1, file);
fclose(file);
//********************
FILE*file;//*** LOAD INT
file = fopen("TextNote.txt", "r+");
fread(&VAR, sizeof(VAR), 1, file);
fclose(file);

A1.textNumber = VAR[0][0];
A2.textNumber = VAR[0][1];<<<<<-----WORK
A3.textNumber = VAR[0][2];
//***********************
FILE*file;//*** LOAD CHAR E PRINT
file = fopen("TextNote.txt", "r+");
fread(&ICON, sizeof(ICON), 1, file);
fclose(file);

//strcpy(A1.text, ICON[0][0]);
sprintf(getclone2(A1.name, 0)->text ,"ICON:%d",ICON[0][0]);<<<<<<<<----NOT WORK


Can yuo help me,please?
Attachments
Image1.png
Image1.png (891 Bytes) Viewed 1589 times
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Saving clones XY postions

Postby Rux » Thu Apr 09, 2009 6:34 pm

DST wrote:http://game-editor.com/forum/viewtopic.php?f=5&t=5703&hilit=+save+user+clones

Thanks a lot! This may take me a while, because there are 15 different things that need to be saved.
:D
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron