The Daily Click ::. Forums ::. Klik Coding Help ::. Max value for horizontal counters ?
 

Post Reply  Post Oekaki 
 

Posted By Message

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
23rd July, 2003 at 11:18:33 -

I'm making a game and i've encountered a problem. I have one of those horizontal counters to count the player's health points. I set its max value to 1000, but how do i make it so if the player's max health is 123 (for example), the max value of the counter is 123 as well ?

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
23rd July, 2003 at 11:40:22 -

Set the counter's maximum to 100 and use this equation:

Life / Max Life * 100

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
23rd July, 2003 at 14:47:13 -

Oh yeah, the % equation. That makes a lot of sense. The problem is, it doesn't work, and that defies all logic. Let's say the hero's got 15 HP and the max value for HP is 25 =

15/25*100 = 60%

=

o Always
- Set counter to value("life")/value("maxlife")*100

...but the counter just sets itself at 0 and I don't understand that

 
n/a

Shen

Possibly Insane

Registered
  14/05/2002
Points
  3497
23rd July, 2003 at 15:05:15 -

You can change the maximum and minimum values at runtime in MMF.

 
gone fishin'

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
23rd July, 2003 at 15:14:58 -

The problem is that Tgf can't deal with decimals.

5/30*100=0,16666666666666666666666666666667

Tgf makes 0,16666666666666666666666666666667 become just 0, and when so what i'm really doing, is this:

0,16666666666666666666666666666667 x 100...

i'm guessing i just have to use one of the math extensions

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
23rd July, 2003 at 16:31:58 -

multiply all of the numbers by something like 1000. then divide by 1000 when you're done. that way you can retain a few decimal places

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Vod Bhat



Registered
  04/07/2003
Points
  3
24th July, 2003 at 21:45:02 -

to get decimals in multiply one of your numbers by 1.0
this will alert the program that you wanna deal with decimals

 
n/a

Vod Bhat



Registered
  04/07/2003
Points
  3
24th July, 2003 at 21:56:46 -

oh and one more thing if you wind up with too many decimal places put the entire equation in parenthesis and put int in front of it like this
Int( 15 * 1.0 / 25 * 100 )

using

 
n/a

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
25th July, 2003 at 13:42:46 -

Change the percentage equation to

Life * 100 / Max Life

and you shouldn't have problems.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click