implement lazy sliders

This commit is contained in:
yugecin 2016-09-27 22:23:14 +02:00
parent 730f55ce20
commit 43548fa058
3 changed files with 42 additions and 0 deletions

View File

@ -596,7 +596,15 @@ public class Options {
DANCE_LAZY_SLIDERS ("Lazy sliders", "LazySliders", "Don't do short sliders", true) { DANCE_LAZY_SLIDERS ("Lazy sliders", "LazySliders", "Don't do short sliders", true) {
@Override @Override
public void click(GameContainer container) { public void click(GameContainer container) {
bool = !bool;
Dancer.LAZY_SLIDERS = bool;
}
@Override
public void read(String s) {
super.read(s);
System.out.println(bool);
Dancer.LAZY_SLIDERS = bool;
} }
}, },

View File

@ -107,6 +107,8 @@ public class Slider extends GameObject {
/** Container dimensions. */ /** Container dimensions. */
private static int containerWidth, containerHeight; private static int containerWidth, containerHeight;
private int repeats;
/** /**
* Initializes the Slider data type with images and dimensions. * Initializes the Slider data type with images and dimensions.
* @param container the game container * @param container the game container
@ -169,6 +171,8 @@ public class Slider extends GameObject {
for (int i = 0; i < tickCount; i++, t += tickTOffset) for (int i = 0; i < tickCount; i++, t += tickTOffset)
ticksT[i] = t; ticksT[i] = t;
} }
repeats = hitObject.getRepeatCount();
} }
@Override @Override
@ -583,6 +587,14 @@ public class Slider extends GameObject {
tickIntervals = 1; tickIntervals = 1;
} }
public Curve getCurve() {
return curve;
}
public int getRepeats() {
return repeats;
}
@Override @Override
public boolean isCircle() { public boolean isCircle() {
return false; return false;

View File

@ -19,7 +19,9 @@ package yugecin.opsudance;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.objects.Slider;
import itdelatrisu.opsu.objects.curves.Vec2f; import itdelatrisu.opsu.objects.curves.Vec2f;
import yugecin.opsudance.movers.Mover; import yugecin.opsudance.movers.Mover;
import yugecin.opsudance.movers.factories.*; import yugecin.opsudance.movers.factories.*;
@ -62,12 +64,17 @@ public class Dancer {
public float x; public float x;
public float y; public float y;
private boolean isCurrentLazySlider;
public static boolean LAZY_SLIDERS;
public Dancer() { public Dancer() {
moverFactory = moverFactories[0]; moverFactory = moverFactories[0];
spinner = spinners[0]; spinner = spinners[0];
} }
public void init(String mapname) { public void init(String mapname) {
isCurrentLazySlider = false;
p = null; p = null;
rand = new Random(mapname.hashCode()); rand = new Random(mapname.hashCode());
dir = 1; dir = 1;
@ -103,6 +110,18 @@ public class Dancer {
public void update(int time, GameObject p, GameObject c) { public void update(int time, GameObject p, GameObject c) {
if (this.p != p) { if (this.p != p) {
this.p = p; this.p = p;
isCurrentLazySlider = false;
// detect lazy sliders, should work pretty good
if (c.isSlider() && LAZY_SLIDERS && Utils.distance(c.start.x, c.start.y, c.end.x , c.end.y) <= Circle.diameter * 0.8f) {
Slider s = (Slider) c;
Vec2f mid = s.getCurve().pointAt(1f);
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
mid = s.getCurve().pointAt(0.5f);
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
isCurrentLazySlider = true;
}
}
}
if (rand.nextInt(2) == 1) { if (rand.nextInt(2) == 1) {
dir *= -1; dir *= -1;
} }
@ -129,6 +148,9 @@ public class Dancer {
c.end = new Vec2f(x, y); c.end = new Vec2f(x, y);
} else { } else {
Vec2f point = c.getPointAt(time); Vec2f point = c.getPointAt(time);
if (isCurrentLazySlider) {
point = c.start;
}
x = point.x; x = point.x;
y = point.y; y = point.y;
} }