putting percentage

Talk about making games.

putting percentage

Postby Sondise » Fri Nov 30, 2007 10:10 pm

How can i put a percentage sistem in the game? :?:
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: putting percentage

Postby Sgt. Sparky » Sat Dec 01, 2007 12:10 am

percentage of what? :D
(I have done this in a few of my games.)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: putting percentage

Postby Sondise » Sat Dec 01, 2007 1:45 am

For example, after each level finished, 5% is add
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: putting percentage

Postby Sgt. Sparky » Sat Dec 01, 2007 4:33 am

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.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: putting percentage

Postby Troodon » Sat Dec 01, 2007 5:33 pm

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)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: putting percentage

Postby Azou » Sat Dec 01, 2007 6:33 pm

Say,Sondise,which kind of game are you making? :D
User avatar
Azou
 
Posts: 514
Joined: Thu Sep 13, 2007 1:12 pm
Score: 35 Give a positive score

Re: putting percentage

Postby Sondise » Sat Dec 01, 2007 7:08 pm

Thank you, it worked! But, when I close the game, and open again, the number continues...
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: putting percentage

Postby Sgt. Sparky » Sat Dec 01, 2007 8:10 pm

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: putting percentage

Postby Sgt. Sparky » Sat Dec 01, 2007 8:10 pm

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: putting percentage

Postby Sondise » Sun Dec 02, 2007 3:00 pm

I would like to do it saving, but i don't know how!
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: putting percentage

Postby Sgt. Sparky » Tue Dec 04, 2007 5:16 pm

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?
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: putting percentage

Postby Sondise » Tue Dec 04, 2007 7:10 pm

No, but you can call me by my e-mail: mnarcisopereira@bol.com.br
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: putting percentage

Postby Sgt. Sparky » Wed Dec 05, 2007 12:13 am

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.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: putting percentage

Postby Sondise » Wed Dec 05, 2007 1:00 am

I'm going to do it soon.
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: putting percentage

Postby Sondise » Tue Dec 11, 2007 7:52 pm

Could you tell me here, please?? :mrgreen:
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron