Binary save file

You must understand the Game Editor concepts, before post here.

Binary save file

Postby speckford123 » Fri Nov 13, 2009 3:55 pm

I had this idea for a while, and decided during some free time I had to write out the plans for it, it's mainly for saving multiple yes or no statements in one variable, it seems useful to me and I'm planning to use it soon :lol:
It's not all proper codes and such, it's just written so I would understand it better when I came back to it

" This codes would be useful for a medabots type game
you can make two seperate game files, one with the fighting etc.
The other with the robot creation and overworld. You save variables
between them. With these codes, saved parts can be done in a binary
style requiring only 1 variable for all unlocked parts.

==================================================

mv=integer;
multvar=real;
vm=real;
cindex=integer;

--------------------------------------------------

<-partview.createactor->

animationdirection("STOPPED");
cindex=cloneindex+1;
animpos=cindex;


<-partview.drawactor->

mv=view.multvar*(1/(10^cindex);

vm=mv;

if(floor(vm*0.5)*2==vm)available=0;
else if(floor(vm*0.5)*2!=vm)available=1;

if(available==0)animpos=0;
else if(available==1)animpos=cindex;


-------------------------------------------------

EX. partview.cloneindex=3;
partview. cindex=4;
view.multvar=010010101;

mv=010010101*(1/(10^4);
~mv=010010101*(0.0001);
~~ mv=01001; //is integer so decimals are lost

vm=01001;

if(floor(01001*0.5)*2==01001)available=0;
~if(floor(00500.5)*2==01001)available=0;
~~ if(00500*2==01001)available=0;
~~~ if(01000==01001)available=0;
else if(floor(01001*0.5)*2!=01001)available=1;
~ else if(floor(00500.5)*2!=01001)available=1;
~~ else if(00500*2!=01001)available=1;
~~~ else if(01000!=01001)available=1;

(available is now 1)

-------------------------------------------------

<-in case of new part->

EX.==> view.newpart=6; //newpart is an integer
view.multvar=010010101;
realv is a real variable
intv is an integer variable


<-view.drawactor->

if(view.newpart>0){
realv=multvar*(1/(10^newpart));
~ realv=010010101*(1/(10^6));
~~ realv=010010101*(1/(1000000);
~~~ realv=010010101*(0.000001);
~~~~ realv=010.010101;
intv=realv; //once again intv is integer so decimals are lost
if(floor(intv*0.5)*2==intv)realv=realv+1;

//realv is now 011.010101;
multvar=realv*(10^newpart);
~ multvar=011.010101*(10^6);
~~ multvar=011.010101*(1000000)
~~~ multvar=011010101;}

//multvar is now updated with the new part"
Last edited by speckford123 on Fri Nov 13, 2009 4:00 pm, edited 1 time in total.
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Re: Binary save file

Postby speckford123 » Fri Nov 13, 2009 3:56 pm

Please let me know if there are errors, I didn't have time to check it over
AND, feel free to let me know if I'm doing it the hard way :lol:

PS: there was supposed to be tabs where I worked out the equations but the forum formatting removed them
nvm, i fixed them with tildas :D
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Re: Binary save file

Postby Hblade » Sun Apr 04, 2010 2:19 am

I havn't tried the code yet, but it looks like it'll work :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Binary save file

Postby Bee-Ant » Tue Apr 13, 2010 12:05 pm

Didn't this code would automatically save vars in binary code ???
Code: Select all
FILE *write=fopen("file.ext","wb");
fwrite(var,sizeof(int),write);
fclose(write);
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


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron