The Daily Click ::. Forums ::. Klik Coding Help ::. percentage?
 

Post Reply  Post Oekaki 
 

Posted By Message

Lukas Hägg



Registered
  02/01/2004
Points
  642
21st April, 2004 at 05:53:53 -

Is it possible in TGF or MMF to have two counter,
one (we call this counter A) set to 100 and the other one (we call this one B) set to X.
Is there someway to make counter A to show the percentage of counter B's maximum value (how many percent is left)?

This would be useful in games where the player has a health bar that increases in value but not in size.

 
Mendokuse...

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
21st April, 2004 at 06:39:18 -

If you look in any math book it will say:

actual value / maximum value * 100

So if a player has 512 HP, and the max is 2324 this equation would say:
512/2324*100 = 22%

If you use TGF, you can't do this because TGF can't handle decimals. Therefore, you have to add some zeroes to the actual value, like this:

(512 * 1000000 ) / 2324 =>
512000000 / 2324 = 220309 =>
220309 / 10000 = 22%

------

In other words, you should have 3 counters.
- Counter A (hidden) the actual value. Can represent health, ammo, experience or whatever.

- Counter B (hidden) the max value. This can be used for max values. Maybe in an RPG game, it would be useful to have the max value always be 25 * PlayerLevel, so the % thing would always work no matter what.

- Counter C (bar, or numbers) The counter seen by the player. If numbers added to the "actual" counter are small and not added all at once, this counter will look smooth when points are gained. So you could have a seperate hidden counter that held the points a player got, and each time a player got points, the points would be added to this counter instead of the score counter.
Then a condition could be set:

- if Counter("PointsHolder") greater than 0, add 1 to score and subtract 1 from "PointsHolder"

---
Hope you get what i mean ...

Image Edited by the Author.

 
n/a

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
21st April, 2004 at 06:51:27 -

try this formula: Set percentage counter to (CounterA * 100 / CounterB)

 
n/a

cake



Registered
  13/12/2002
Points
  1173
21st April, 2004 at 08:11:35 -

I believe in MMF:

((CounterA + 0.0)/(CounterB + 0.0)) * 100

Should do the trick

 
n/a
   

Post Reply



 



Advertisement

Worth A Click