use better spinnerdelay

This commit is contained in:
yugecin 2016-10-04 13:43:08 +02:00
parent b3899fb3e5
commit 5c2fc16124
10 changed files with 35 additions and 12 deletions

View File

@ -633,10 +633,10 @@ public class Options {
} }
}, },
DANCE_SPINNER_DELAY ("Spinner delay", "SpinnerDelay", "Fiddle with this if spinner goes too fast. Some spinners don't use delays.", Spinner.DELAY, 0, 20) { DANCE_SPINNER_DELAY ("Spinner delay", "SpinnerDelay", "Fiddle with this if spinner goes too fast.", Spinner.DELAY, 0, 20) {
@Override @Override
public String getValueString() { public String getValueString() {
return String.format("%d frames", val); return String.format("%dms", val);
} }
@Override @Override

View File

@ -637,6 +637,7 @@ public class Game extends BasicGameState {
throws SlickException { throws SlickException {
UI.update(delta); UI.update(delta);
Pippi.update(delta); Pippi.update(delta);
yugecin.opsudance.spinners.Spinner.update(delta);
int mouseX = input.getMouseX(), mouseY = input.getMouseY(); int mouseX = input.getMouseX(), mouseY = input.getMouseY();
skipButton.hoverUpdate(delta, mouseX, mouseY); skipButton.hoverUpdate(delta, mouseX, mouseY);
if (isReplay || GameMod.AUTO.isActive()) if (isReplay || GameMod.AUTO.isActive())

View File

@ -36,6 +36,10 @@ public class BeamSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
if (!waitForDelay()) {
return point;
}
index = ++index % 4; index = ++index % 4;
final int MOD = 60; final int MOD = 60;

View File

@ -34,7 +34,9 @@ public class CircleSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
ang += 15; if (waitForDelay()) {
ang += 15;
}
double rad = Options.width / 4.0f; double rad = Options.width / 4.0f;

View File

@ -63,7 +63,7 @@ public class CubeSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
if( ++index >= 16 ) if(waitForDelay() && ++index >= 16 )
{ {
index = 0; index = 0;
azimuth += 2.0d; azimuth += 2.0d;

View File

@ -34,7 +34,9 @@ public class DonutSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
ang += 15; if (waitForDelay()) {
ang += 15;
}
double rad = Options.width / 4.0f; double rad = Options.width / 4.0f;

View File

@ -35,7 +35,9 @@ public class HalfCircleSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
ang += 15; if (waitForDelay()) {
ang += 15;
}
if( ang > skipang - 160 ) if( ang > skipang - 160 )
{ {

View File

@ -32,7 +32,9 @@ public class LessThanThreeSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
angle += 18; if (waitForDelay()) {
angle += 18;
}
if( angle > 360 ) angle = 0; if( angle > 360 ) angle = 0;
double theta = angle / 180d * Math.PI; double theta = angle / 180d * Math.PI;
double[] pos = new double[] { double[] pos = new double[] {

View File

@ -38,8 +38,7 @@ public class RektCircleSpinner extends Spinner {
@Override @Override
public double[] getPoint() public double[] getPoint()
{ {
if( ++delay < DELAY ) if (!waitForDelay()) {
{
return point; return point;
} }
delay = 0; delay = 0;

View File

@ -22,7 +22,7 @@ public abstract class Spinner {
private double[][] points; private double[][] points;
private int length; private int length;
private int index; private int index;
private int delay; private static int delay;
public static int DELAY = 3; public static int DELAY = 3;
public abstract void init(); public abstract void init();
@ -33,11 +33,22 @@ public abstract class Spinner {
} }
public double[] getPoint() { public double[] getPoint() {
if (++delay > DELAY) { if (waitForDelay()) {
index = ++index % length; index = ++index % length;
delay = 0;
} }
return points[index]; return points[index];
} }
public boolean waitForDelay() {
if (delay >= DELAY) {
delay = 0;
return true;
}
return false;
}
public static void update(int delta) {
delay += delta;
}
} }