Page 1 of 2

putting percentage

PostPosted: Fri Nov 30, 2007 10:10 pm
by Sondise
How can i put a percentage sistem in the game? :?:

Re: putting percentage

PostPosted: Sat Dec 01, 2007 12:10 am
by Sgt. Sparky
percentage of what? :D
(I have done this in a few of my games.)

Re: putting percentage

PostPosted: Sat Dec 01, 2007 1:45 am
by Sondise
For example, after each level finished, 5% is add

Re: putting percentage

PostPosted: Sat Dec 01, 2007 4:33 am
by Sgt. Sparky
Sondise wrote:For example, after each level finished, 5% is add

Make an integer (global) called per.
after each level is finished put this code:
FILE*file;
per += 5;//5 percent.
file = fopen("percentage.per", "w+b");//write binary.
fwrite(&per, sizeof(per), 1, file);
fclose(file);

Put this code on the create actor of the view:

FILE*file;
file = fopen("percentage.per", "r+b");//read binary.
fread(&per, sizeof(per), 1, file);
fclose(file);

And then create a text actor to display the variable called per, use this code on the text actors draw actor event:

sprintf(text, "Percent complete: %%%03d.", per);
//If the percentage complete was 15, it would display as Percent complete: %015.

Re: putting percentage

PostPosted: Sat Dec 01, 2007 5:33 pm
by Troodon
Whoa Sparky are you trying to do it the hardest way?

Maybe he just meant how to make 5% add in a variable.
That would be one line:

myvariable *= 1,05;

that adds 5% to your variable. (Which can control a text actor or something)

Re: putting percentage

PostPosted: Sat Dec 01, 2007 6:33 pm
by Azou
Say,Sondise,which kind of game are you making? :D

Re: putting percentage

PostPosted: Sat Dec 01, 2007 7:08 pm
by Sondise
Thank you, it worked! But, when I close the game, and open again, the number continues...

Re: putting percentage

PostPosted: Sat Dec 01, 2007 8:10 pm
by Sgt. Sparky
Sondise wrote:Thank you, it worked! But, when I close the game, and open again, the number continues...

Oh, It is not a save and load game?
Just remove the stuff the stuff that has to do with writing the file. :D

Re: putting percentage

PostPosted: Sat Dec 01, 2007 8:10 pm
by Sgt. Sparky
Sgt. Sparky wrote:
Sondise wrote:Thank you, it worked! But, when I close the game, and open again, the number continues...

Oh, sorry, I thought it was a save and load game.
Just remove the stuff the stuff that has to do with writing the file. :D

Re: putting percentage

PostPosted: Sun Dec 02, 2007 3:00 pm
by Sondise
I would like to do it saving, but i don't know how!

Re: putting percentage

PostPosted: Tue Dec 04, 2007 5:16 pm
by Sgt. Sparky
Sondise wrote:I would like to do it saving, but i don't know how!

I can show you. :D
Do you have MSN/Windows Live messenger or AIM?

Re: putting percentage

PostPosted: Tue Dec 04, 2007 7:10 pm
by Sondise
No, but you can call me by my e-mail: mnarcisopereira@bol.com.br

Re: putting percentage

PostPosted: Wed Dec 05, 2007 12:13 am
by Sgt. Sparky
Sondise wrote:No, but you can call me by my e-mail: mnarcisopereira@bol.com.br

Okay. :D
Do you think you could get AIM or MSN messenger?
E-mailing is slower and not as effective.

Re: putting percentage

PostPosted: Wed Dec 05, 2007 1:00 am
by Sondise
I'm going to do it soon.

Re: putting percentage

PostPosted: Tue Dec 11, 2007 7:52 pm
by Sondise
Could you tell me here, please?? :mrgreen: