From 041e0dd4390c1575676848c47d0ac660a42fdcfe Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 4 Dec 2016 15:00:07 +0100 Subject: [PATCH] correct the position/speed when exiting sliders --- src/yugecin/opsudance/Dancer.java | 12 ++++++++++++ .../opsudance/movers/QuadraticBezierMover.java | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/yugecin/opsudance/Dancer.java b/src/yugecin/opsudance/Dancer.java index b8b63d94..25be5acf 100644 --- a/src/yugecin/opsudance/Dancer.java +++ b/src/yugecin/opsudance/Dancer.java @@ -40,6 +40,8 @@ import yugecin.opsudance.movers.slidermovers.InheritedSliderMoverController; import yugecin.opsudance.movers.slidermovers.SliderMoverController; import yugecin.opsudance.spinners.*; +import java.awt.*; + public class Dancer { public static MoverFactory[] moverFactories = new MoverFactory[] { @@ -219,6 +221,16 @@ public class Dancer { c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]); } + // specific mover stuff + if (p.isSlider() && sliderMoverController instanceof DefaultSliderMoverController) { + Vec2f st = p.getPointAt(p.getEndTime() - 10); + Vec2f en = p.getPointAt(p.getEndTime()); + //double atan = Math.atan2(en.y - st.y, en.x - st.x); + double distance = Utils.distance(st.x, st.y, en.x, en.y); + QuadraticBezierMover.p = new Point((int) st.x, (int) st.y); + QuadraticBezierMover.setPrevspeed(distance, 10); + } + createNewMover(); } diff --git a/src/yugecin/opsudance/movers/QuadraticBezierMover.java b/src/yugecin/opsudance/movers/QuadraticBezierMover.java index e9fe881a..de3df8d2 100644 --- a/src/yugecin/opsudance/movers/QuadraticBezierMover.java +++ b/src/yugecin/opsudance/movers/QuadraticBezierMover.java @@ -25,7 +25,7 @@ import java.awt.*; public class QuadraticBezierMover extends Mover { public static int aggressiveness = 50; - private static Point p; + public static Point p; private static double prevspeed; public static void reset() { @@ -33,6 +33,10 @@ public class QuadraticBezierMover extends Mover { prevspeed = 0; } + public static void setPrevspeed(double distance, int timedelta) { + prevspeed = distance * aggressiveness / timedelta; + } + private int startTime; private int totalTime;