converting to percent

Game Editor comments and discussion.

converting to percent

Postby DarkParadox » Sat Jan 12, 2008 5:31 pm

how do you convert transperancy into a percent out of one hundred,
like 0.01 = 1% and 0.47 = 47%
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: converting to percent

Postby Kalladdolf » Sat Jan 12, 2008 5:41 pm

yup, that's exactly it
0 = 0% and 1 = 100%

0.5 = 50 %
0.345 = 34.5 %

and so on =D
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: converting to percent

Postby DarkParadox » Sat Jan 12, 2008 5:49 pm

it would be to long of a code, can you tell me how to make it shorter?
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: converting to percent

Postby Kalladdolf » Sat Jan 12, 2008 6:08 pm

Code: Select all
var = transp*100;

so it'll just turn var into a basic number, there is no percent expression in the GE language.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: converting to percent

Postby DocRabbit » Tue Jan 29, 2008 1:51 pm

Here is a sample code that would do it. It is from my Health Bar demo, but the concept should work the same.
Code: Select all
sprintf(texthealth.text,"%d%%",Goober.health);


Replace Goober.health with your transparency increased *100 variable.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron