math question
Blitz3D Forums/Blitz3D Beginners Area/math question
| ||
How do you make 1500 0% of 3000? 1500/3000*100 = 50 and I need it to be 0. Hope that makes sense. Those numbers will increase over time so I need an equation. |
| ||
. |
| ||
The reason I ask is because I'm trying to track experience and levels. If the player gains 200 experience, he/she reaches level 2. Level 3 requires 700 experience. Should I be resetting experience to zero then requiring the person to gain 700 experience to reach level 3 or keep the experience where it is and boost the level 3 experience requirement higher? |
| ||
0% of anything will be 0 by definition, 0% of a billion hitpoints is plain old zero. You may just want to add a base amount to the percentages, e.g. instead of trying to calculate a fraction of 3000, just calculate a percentage of 1500 and add the 1500 start value to the end result. (e.g. 10% of the second 1500-3000 tier would be (1500*0.10)+1500=1650) |
| ||
Makes sense xlsior but this is for a progress meter. Right now its: DrawRect3D(xpimage,-790,64,100,100,(playerxp/xpneeded)*100,8) Once the player reaches level 2, playerxp is at 500 and xpneeded is at 1000 (to reach level 3) which calculates to 50% and makes the progress bar go up halfway since the width is based on 0-100%. I want the bar to go back down to zero when they reach a new level. |
| ||
Kinda answering my own question here. I don't think I should be basing the meter width off playerxp and xpneeded since the leveling check is handled seperately. I just can't wrap my head around calculating the right part for the meter! |
| ||
http://imgur.com/HfjdAzJ In this shot my player is level 4, has 2975 XP and requires 2025 more to reach 5000 - which is required for level 5. 2500 XP was required to reach level 4. (2975/5000)*100 = 59.5 which makes the meter reflect 59.5%. That's my dilemma. I've coded myself dumb. So 2500 - 5000 needs to reflect 0 - 100%. 2975 is 475 XP points into level 4. Base is 2500. So... ((playerxp-base)/playerxp)*100 = 15.9. Nope. ((playerxp-base)/base)*100 = 19. Maybe. Edit: Nope. |
| ||
it's the current distance divided by the full distance. startXP = 2500 ;Each level has a different start and end values. endXP = 5000 levelRange = endXP - startXP playerProgress = playerXP - startXP ;Here playerXP is expected to be greater than startXP. percent# = playerProgress / levelRange ;Goes from zero when playerXP=startXP to 1 when playerXP=endXP. |
| ||
That works Kryzon thanks. Here's the formula: DrawRect3D(xpimage,-790,64,100,100,((playerxp-xpbase)/(xpneeded-xpbase))*100,8) |
| ||
It was only by your third post that I understood what you were even after - the first and second post without any context made it really hard to work out what you were even trying to do or asking. |
| ||
I know Matty...sorry about that. |