this isn't entirely programming-related, but i figure any good programmer can probably help me out here
i'm in the process of building my GUI/HUD in darkbasic, and i've run into a bit of a snag - i am trying to make a visible 'health bar' (doesn't actually represent health, but another element in the game) that pretty much just does what health bars do (fill, and drain in accordance to the health variables). unfortunately i am terrible with math, and i'm having a hard time trying to come up with a process/algorithm to translate these health variables into a visual health bar.
the health bar in question is 158 pixels wide, and i'm using darkbasic's primitive 'draw box' functions to represent it (to good effect, mind you), so what i need to achieve is a process that can get an accurate percentage of [current health] in relation to [max health], and somehow translate that further into a whole number between 0 and 158, 0 being 0% and 158 being 100%. :l
btw, just so i'm clear, it's not the syntax i'm having any trouble with. i'm efficient with darkbasic, i just dont know how to pull off these kinds of functions with basic math. i'm giving myself a huge headache trying to figure this one out, so if anyone can help in any way i'd appreciate it very much!
here's a mock-up of the meter in question, for whatever it's worth;
i'm in the process of building my GUI/HUD in darkbasic, and i've run into a bit of a snag - i am trying to make a visible 'health bar' (doesn't actually represent health, but another element in the game) that pretty much just does what health bars do (fill, and drain in accordance to the health variables). unfortunately i am terrible with math, and i'm having a hard time trying to come up with a process/algorithm to translate these health variables into a visual health bar.
the health bar in question is 158 pixels wide, and i'm using darkbasic's primitive 'draw box' functions to represent it (to good effect, mind you), so what i need to achieve is a process that can get an accurate percentage of [current health] in relation to [max health], and somehow translate that further into a whole number between 0 and 158, 0 being 0% and 158 being 100%. :l
btw, just so i'm clear, it's not the syntax i'm having any trouble with. i'm efficient with darkbasic, i just dont know how to pull off these kinds of functions with basic math. i'm giving myself a huge headache trying to figure this one out, so if anyone can help in any way i'd appreciate it very much!
here's a mock-up of the meter in question, for whatever it's worth;