Home
Help
Search
Calendar
Login
Register
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
New forum theme up and running!
Charas-Project
»
Game Creation
»
Requests
»
RPG Maker Programming
»
Variables to procentages
« previous
next »
Print
Pages: [
1
]
Author
Topic: Variables to procentages (Read 1719 times)
SilverBlade
YiN-YaNg
Associate
Posts: 157
/
Variables to procentages
«
on:
October 01, 2006, 08:11:27 AM »
I'm making a 'HP-Bar system': a bar that shows your HP is in the left corner of the screen.
The only problem is the programming, I could make a branch for every sort of HP he could get, example: Branch if his total HP is 30=that would be a full bar, but then I have to do it also for when he's 35, 40, 45...and so on!
So I was wondering, can't I set his Total HP to 100%. This way it would be way more accurate and easier. I just can't figure how to do it(example:
Branch if variable HP equals to 60%
Show picture 1: HP Bar 60%...
Do you know what I mean? Please help me!
Logged
-------Yin Yang-Thread of Memories----
Story: 70% complete
Battle System: 50% complete
Demo Version 1.1:
http://rapidshare.com/files/12421951/Yin-Yang.rar.html
WarxePB
Action Sue
Royal
Posts: 3,601
What killed the dinosaurs?
(No subject)
«
Reply #1 on:
October 01, 2006, 02:09:50 PM »
To get a percentage from HP, first use a Variable Operation to get the hero's current HP. Then, use another Variable Operation to multiply it by 100, and one more that divides it by the hero's max HP. So it would look like:
<>Variable Operation: Var[0001] Set, Hero HP
<>Variable Operation: Var[0001] *, 100
<>Variable Operation: Var[0001] /, Hero Max HP
Then, as you said, you need branches for every possible position on the bar (1-100).
Logged
Blog:
The Gigaverse
Twitter:
Initial Chaos
DragonBlaze
A Wild DB Appeared!
Royal
Posts: 3,329
(No subject)
«
Reply #2 on:
October 01, 2006, 03:22:29 PM »
Yeah, do what Warxe said.
If you know how many pictures you hae to display it, it'll be easier to just multiply the variable be 1 less than the amount of pictures you have instead of 100.
So lets say you have 21 pictures, you would multiply by 20.
Then you can set it up like:
if var = 0, show empty par
if var = 1, show next bar
...
If var = 20, show full bar.
Logged
Hell Yeah! Just recovered all my old rm2k/3 games from my 10 year old, broken laptop hard drive that had been formatted and had a new OS installed on it. Oh, and I did all of this from my phone. WIN
Print
Pages: [
1
]
« previous
next »
Charas-Project
»
Game Creation
»
Requests
»
RPG Maker Programming
»
Variables to procentages