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?
velocity = velocity*1.2*(101-health)^0.1;
setLocation(getX()+velocity, getY());
velocityCoefficient=Math.pow((healthCoefficient),x)
healthCoefficient=101-health;
private float x = 0.1f;