Page 1 of 1

Binary save file

PostPosted: Fri Nov 13, 2009 3:55 pm
by speckford123
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"

Re: Binary save file

PostPosted: Fri Nov 13, 2009 3:56 pm
by speckford123
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

Re: Binary save file

PostPosted: Sun Apr 04, 2010 2:19 am
by Hblade
I havn't tried the code yet, but it looks like it'll work :D

Re: Binary save file

PostPosted: Tue Apr 13, 2010 12:05 pm
by Bee-Ant
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);