So in the game I am creating I'm trying to create a mechanic where the player accelerates faster the lower his health is.
The basic maths for the line I'm trying to make is:
I'm then going to move the player with:
To do the power in the code I tried to use this code:
when
and
The problem is that for velocity to work in the setLocation line it needs to be an int, but 0.1 needs to be a float/double and Math.pow only returns doubles. Any way around this?
1 | velocity = velocity* 1.2 *( 101 -health)^ 0.1 ; |
1 | setLocation(getX()+velocity, getY()); |
1 | velocityCoefficient=Math.pow((healthCoefficient),x) |
1 | healthCoefficient= 101 -health; |
1 | private float x = 0 .1f; |