Forum Topic: AS: Linear Increasment

(2,247 views • 10 replies)

This topic is 1 page long.

<< < > >>
None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 02:04 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

let's say you have a lifebar, whose max width is 300 and it's min width is 30, now you want that life bar's width to be equal to the right amount each time of life, your problam is, life goes between 10 and 37 :P

This is how it's done:

so basically you have 2 min values, 30 and 10, that's your first 'point.'
you also have 2 max values, 300 and 37, that's your second 'point'

in math, there is only 1 streight line between two points, our points are (10,30) and (37,300), remmember the first value is the variable (life) and the second variable is the function (the stuff you want to change according to the first value)

you can find the angle of a line with this formula (y2-y1)/(x2-x1), in our case (300-30)/(37-10),
this is 270/27, which is 10 ;) so we now know that we must increase the width by 10 for every hp.

now let's make this into a formula
y-y1=m(x-x1);
so y-30=10(x-10);
lifebar._width=10*hp-100+30;
remmember adding a check for hp>10, otherwise you're off limit

hope I helped, post questions


None

Inglor

Reply To Post Reply & Quote

Posted at: 6/28/05 02:06 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

oops, forgot :P

AS: main


None

noob-toast

Reply To Post Reply & Quote

Posted at: 8/29/05 12:04 AM

noob-toast NEUTRAL LEVEL 08

Sign-Up: 05/18/04

Posts: 1,288

Hey Inglor, I found a different way to do it, and I find it a bit easier to understand. I'm not saying your way is bad, but I am saying it's a bit confusing, but then again, I'm more or a listener, not a reader.

These new signatures can suck on mah balls. My lolis don't fit in. Lol wut what are you guys still doing on NG, move on.

BBS Signature

None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 8/29/05 12:56 AM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,318

At 8/29/05 12:04 AM, KinZo wrote: grr inglor = bad. i found better way. but i wont tell you because i have an itchy vagina

the quote says how i feel

Some times my "L" key decides not to work.


None

noob-toast

Reply To Post Reply & Quote

Posted at: 8/29/05 01:23 AM

noob-toast NEUTRAL LEVEL 08

Sign-Up: 05/18/04

Posts: 1,288

Someone's unhappy. :( Here is some good news though. I hope.

These new signatures can suck on mah balls. My lolis don't fit in. Lol wut what are you guys still doing on NG, move on.

BBS Signature

None

onnet5

Reply To Post Reply & Quote

Posted at: 10/23/05 01:34 PM

onnet5 NEUTRAL LEVEL 02

Sign-Up: 09/20/05

Posts: 38

I don't understand. Why is there a y and x axis when a healthbar only goes one way...and what's with the m?


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 10/23/05 03:40 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,542

At 10/23/05 01:34 PM, onnet5 wrote: I don't understand. Why is there a y and x axis when a healthbar only goes one way...and what's with the m?

lol @ you

My social worker says im special!

BBS Signature

None

shazwoogle

Reply To Post Reply & Quote

Posted at: 11/15/05 02:08 AM

shazwoogle NEUTRAL LEVEL 11

Sign-Up: 09/27/04

Posts: 2,681

what i use it just a simple percentage formula leant in grade 8 =P

A/B*100


None

GeoffCLogan

Reply To Post Reply & Quote

Posted at: 11/15/05 03:04 AM

GeoffCLogan LIGHT LEVEL 11

Sign-Up: 04/25/04

Posts: 4,423

At 11/15/05 02:08 AM, shazwoogle wrote: what i use it just a simple percentage formula leant in grade 8 =P

A/B*100

I just use xscale with a moved registration point. Am I a bad person?


None

Newsdee

Reply To Post Reply & Quote

Posted at: 11/15/05 03:16 AM

Newsdee LIGHT LEVEL 18

Sign-Up: 01/21/05

Posts: 650

Hah, pwned.
I was going to post a formula based on percentage but I ended up finding the same as Inglor.
Basically the slop of the curve in his post is the percentage (hp %), that is then applied to the second range (the lifebar). Here's the proof:

maxLife = 37
minLife = 10

if hp = 10 -> 0% width
if hp = 37 -> 100% width

width% = (hp - minLife)/(maxLife - minLife)
width% = (hp - 10)/(37-10)

lifeBar._width = width% * (maxBar - minBar) + minBar
lifeBar._width = (hp - 10)/(37-10) * 270 + 30
lifeBar._width = (hp-10)/27 * 270 + 30
lifeBar._width = (hp-10)*10 + 30
lifeBar._width = 10*hp - 100 + 30 (Inglor's formula above)

QED. :-)


None

Newsdee

Reply To Post Reply & Quote

Posted at: 11/15/05 03:23 AM

Newsdee LIGHT LEVEL 18

Sign-Up: 01/21/05

Posts: 650

And here's the generic formula (regardless of values used):

_width = (hp - minLife)/(maxLife - minLife) * (maxBar - minBar) + minBar
_width = (hp - minLife) * (maxBar - MinBar)/(maxLife-minLife) + minBar

_width = (hp - minLife) * [angle of line] + minBar
Where [angle of line] is (maxBar - minBar)/(maxLife - minLife)


All times are Eastern Standard Time (GMT -5) | Current Time: 12:37 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!