Revert "Revert "Further implementation of "weighted" spinner""

This reverts commit 582af96e12.
This commit is contained in:
Terrence 2015-02-09 17:58:04 -06:00
parent 582af96e12
commit 6c7aac53f4

View File

@ -38,8 +38,8 @@ import org.newdawn.slick.Image;
*/
public class Spinner implements HitObject {
/** The rate at which the spinner slows down in radians/second^2. */
private static final float angularDrag = 500f;
/** The rate at which the spinner slows down in rotations/second^2. */
private static final float angularDrag = 20f;
/** Container dimensions. */
private static int width, height;
@ -59,7 +59,7 @@ public class Spinner implements HitObject {
/** The total number of rotations needed to clear the spinner. */
private float rotationsNeeded;
/** The current angular velocity of the spinner in radians/second. */
/** The current angular velocity of the spinner in rotations/second. */
private float angularVelocity;
/**
@ -126,6 +126,10 @@ public class Spinner implements HitObject {
if (extraRotations > 0)
data.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
}
// rotations per minute
g.setColor(new Color(0,0,0));
g.drawString(String.format("RPM: %d", Math.round(angularVelocity * 60)), 100, 100);
}
/**
@ -179,9 +183,11 @@ public class Spinner implements HitObject {
return false;
}
// not spinning: nothing to do
// not spinning: spinner slows down
if (!Utils.isGameKeyPressed()) {
lastAngle = -1f;
angularVelocity = Math.max(0, angularVelocity - angularDrag * delta / 1000);
rotate(angularVelocity * (float)Math.PI * 2 * delta / 1000);
return false;
}
@ -193,10 +199,10 @@ public class Spinner implements HitObject {
if (lastAngle >= 0f) { // skip initial clicks
float angleDiff = Math.abs(lastAngle - angle);
if (angleDiff < Math.PI / 2) { // skip huge angle changes...
angularVelocity = Math.max(angularVelocity - angularDrag * delta / 1000,
angularVelocity = (float)Math.max(angularVelocity - angularDrag * delta / 1000,
angleDiff / (Math.PI * 2) / ((float)delta / 1000));
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
rotate(angularVelocity * delta / 1000);
rotate(angularVelocity * (float)Math.PI * 2 * delta / 1000);
}
}