2014-06-30 04:17:04 +02:00
|
|
|
/*
|
|
|
|
* opsu! - an open-source osu! client
|
2015-01-16 18:05:44 +01:00
|
|
|
* Copyright (C) 2014, 2015 Jeffrey Han
|
2014-06-30 04:17:04 +02:00
|
|
|
*
|
|
|
|
* opsu! is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* opsu! is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package itdelatrisu.opsu.objects;
|
|
|
|
|
2015-01-30 02:36:23 +01:00
|
|
|
import itdelatrisu.opsu.GameData;
|
2015-04-08 08:05:12 +02:00
|
|
|
import itdelatrisu.opsu.GameData.HitObjectType;
|
2014-07-04 22:41:52 +02:00
|
|
|
import itdelatrisu.opsu.GameImage;
|
2014-07-16 22:01:36 +02:00
|
|
|
import itdelatrisu.opsu.GameMod;
|
2015-05-25 11:33:12 +02:00
|
|
|
import itdelatrisu.opsu.Options;
|
2014-07-02 01:32:03 +02:00
|
|
|
import itdelatrisu.opsu.Utils;
|
2015-05-17 03:25:19 +02:00
|
|
|
import itdelatrisu.opsu.beatmap.Beatmap;
|
2015-05-17 03:42:03 +02:00
|
|
|
import itdelatrisu.opsu.beatmap.HitObject;
|
2015-01-30 02:36:23 +01:00
|
|
|
import itdelatrisu.opsu.objects.curves.Curve;
|
2015-09-05 19:53:42 +02:00
|
|
|
import itdelatrisu.opsu.objects.curves.Vec2f;
|
2014-06-30 04:17:04 +02:00
|
|
|
import itdelatrisu.opsu.states.Game;
|
2015-08-21 03:02:23 +02:00
|
|
|
import itdelatrisu.opsu.ui.Colors;
|
2015-09-16 17:19:23 +02:00
|
|
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
import org.newdawn.slick.Color;
|
|
|
|
import org.newdawn.slick.GameContainer;
|
2015-01-16 09:47:37 +01:00
|
|
|
import org.newdawn.slick.Graphics;
|
2014-06-30 04:17:04 +02:00
|
|
|
import org.newdawn.slick.Image;
|
2016-09-29 23:34:11 +02:00
|
|
|
import yugecin.opsudance.Dancer;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data type representing a slider object.
|
|
|
|
*/
|
2016-09-27 18:26:53 +02:00
|
|
|
public class Slider extends GameObject {
|
2015-03-19 08:04:35 +01:00
|
|
|
/** Slider ball frames. */
|
2015-03-16 04:05:27 +01:00
|
|
|
private static Image[] sliderBallImages;
|
2015-03-19 08:04:35 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Slider movement speed multiplier. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private static float sliderMultiplier = 1.0f;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Rate at which slider ticks are placed. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private static float sliderTickRate = 1.0f;
|
2015-06-30 02:22:38 +02:00
|
|
|
|
|
|
|
/** Follow circle radius. */
|
2015-04-05 17:24:05 +02:00
|
|
|
private static float followRadius;
|
2015-06-30 02:22:38 +02:00
|
|
|
|
|
|
|
/** The diameter of hit circles. */
|
2015-04-05 17:24:05 +02:00
|
|
|
private static float diameter;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-05-17 03:42:03 +02:00
|
|
|
/** The associated HitObject. */
|
|
|
|
private HitObject hitObject;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-03-13 01:12:43 +01:00
|
|
|
/** The scaled starting x, y coordinates. */
|
|
|
|
protected float x, y;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The associated Game object. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private Game game;
|
|
|
|
|
2015-01-27 09:19:39 +01:00
|
|
|
/** The associated GameData object. */
|
|
|
|
private GameData data;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The color of this slider. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private Color color;
|
2016-09-30 19:05:53 +02:00
|
|
|
private Color mirrorColor;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-01-30 02:36:23 +01:00
|
|
|
/** The underlying Curve. */
|
|
|
|
private Curve curve;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The time duration of the slider, in milliseconds. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private float sliderTime = 0f;
|
2015-01-16 21:44:13 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The time duration of the slider including repeats, in milliseconds. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private float sliderTimeTotal = 0f;
|
|
|
|
|
2015-06-30 02:22:38 +02:00
|
|
|
/** Whether or not the result of the initial hit circle has been processed. */
|
|
|
|
private boolean sliderClickedInitial = false;
|
|
|
|
|
|
|
|
/** Whether or not the slider was held to the end. */
|
|
|
|
private boolean sliderHeldToEnd = false;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Whether or not to show the follow circle. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private boolean followCircleActive = false;
|
2015-01-16 21:44:13 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Whether or not the slider result ends the combo streak. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private boolean comboEnd;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The number of repeats that have passed so far. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private int currentRepeats = 0;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The t values of the slider ticks. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private float[] ticksT;
|
2015-01-16 21:44:13 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The tick index in the ticksT[] array. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private int tickIndex = 0;
|
2015-01-16 21:44:13 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Number of ticks hit and tick intervals so far. */
|
2014-06-30 04:17:04 +02:00
|
|
|
private int ticksHit = 0, tickIntervals = 1;
|
|
|
|
|
2015-03-15 20:38:04 +01:00
|
|
|
/** Container dimensions. */
|
|
|
|
private static int containerWidth, containerHeight;
|
|
|
|
|
2016-09-27 22:23:14 +02:00
|
|
|
private int repeats;
|
|
|
|
|
2016-09-29 23:22:41 +02:00
|
|
|
private static Color curveColor = new Color(0, 0, 0, 20);
|
2016-09-29 22:45:16 +02:00
|
|
|
|
2016-10-01 13:12:02 +02:00
|
|
|
public static double bpm;
|
|
|
|
|
2016-10-01 14:46:39 +02:00
|
|
|
public float pixelLength;
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Initializes the Slider data type with images and dimensions.
|
|
|
|
* @param container the game container
|
2015-08-31 02:01:40 +02:00
|
|
|
* @param circleDiameter the circle diameter
|
2015-05-17 03:25:19 +02:00
|
|
|
* @param beatmap the associated beatmap
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2015-08-31 02:01:40 +02:00
|
|
|
public static void init(GameContainer container, float circleDiameter, Beatmap beatmap) {
|
2015-03-15 20:38:04 +01:00
|
|
|
containerWidth = container.getWidth();
|
|
|
|
containerHeight = container.getHeight();
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-08-31 02:01:40 +02:00
|
|
|
diameter = circleDiameter * HitObject.getXMultiplier(); // convert from Osupixels (640x480)
|
2015-06-30 02:22:38 +02:00
|
|
|
int diameterInt = (int) diameter;
|
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
followRadius = diameter / 2 * 3f;
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
// slider ball
|
2015-08-24 03:41:09 +02:00
|
|
|
if (GameImage.SLIDER_BALL.hasBeatmapSkinImages() ||
|
|
|
|
(!GameImage.SLIDER_BALL.hasBeatmapSkinImage() && GameImage.SLIDER_BALL.getImages() != null))
|
2015-01-21 23:10:31 +01:00
|
|
|
sliderBallImages = GameImage.SLIDER_BALL.getImages();
|
|
|
|
else
|
|
|
|
sliderBallImages = new Image[]{ GameImage.SLIDER_BALL.getImage() };
|
|
|
|
for (int i = 0; i < sliderBallImages.length; i++)
|
2016-10-01 15:57:41 +02:00
|
|
|
sliderBallImages[i] = sliderBallImages[i].getScaledCopy(diameterInt, diameterInt);
|
2015-03-19 08:04:35 +01:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
GameImage.SLIDER_FOLLOWCIRCLE.setImage(GameImage.SLIDER_FOLLOWCIRCLE.getImage().getScaledCopy(diameterInt * 259 / 128, diameterInt * 259 / 128));
|
|
|
|
GameImage.REVERSEARROW.setImage(GameImage.REVERSEARROW.getImage().getScaledCopy(diameterInt, diameterInt));
|
|
|
|
GameImage.SLIDER_TICK.setImage(GameImage.SLIDER_TICK.getImage().getScaledCopy(diameterInt / 4, diameterInt / 4));
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-05-17 03:25:19 +02:00
|
|
|
sliderMultiplier = beatmap.sliderMultiplier;
|
|
|
|
sliderTickRate = beatmap.sliderTickRate;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
2015-05-17 03:42:03 +02:00
|
|
|
* @param hitObject the associated HitObject
|
2014-06-30 04:17:04 +02:00
|
|
|
* @param game the associated Game object
|
2015-01-27 09:19:39 +01:00
|
|
|
* @param data the associated GameData object
|
2016-09-30 21:32:24 +02:00
|
|
|
* @param comboColorIndex index of the combo color of this slider
|
2014-06-30 04:17:04 +02:00
|
|
|
* @param comboEnd true if this is the last hit object in the combo
|
|
|
|
*/
|
2016-09-30 21:32:24 +02:00
|
|
|
public Slider(HitObject hitObject, Game game, GameData data, int comboColorIndex, boolean comboEnd) {
|
2014-06-30 04:17:04 +02:00
|
|
|
this.hitObject = hitObject;
|
|
|
|
this.game = game;
|
2015-01-27 09:19:39 +01:00
|
|
|
this.data = data;
|
2014-06-30 04:17:04 +02:00
|
|
|
this.comboEnd = comboEnd;
|
2016-09-30 21:32:24 +02:00
|
|
|
color = Dancer.colorOverride.getColor(comboColorIndex);
|
|
|
|
mirrorColor = Dancer.colorMirrorOverride.getColor(comboColorIndex);
|
2015-03-31 05:06:52 +02:00
|
|
|
updatePosition();
|
2015-03-28 13:11:43 +01:00
|
|
|
|
2016-10-01 14:46:39 +02:00
|
|
|
this.pixelLength = hitObject.getPixelLength();
|
|
|
|
|
2015-03-28 13:11:43 +01:00
|
|
|
// slider time calculations
|
2015-09-02 17:51:52 +02:00
|
|
|
this.sliderTime = hitObject.getSliderTime(sliderMultiplier, game.getBeatLength());
|
2015-03-28 13:11:43 +01:00
|
|
|
this.sliderTimeTotal = sliderTime * hitObject.getRepeatCount();
|
|
|
|
|
|
|
|
// ticks
|
|
|
|
float tickLengthDiv = 100f * sliderMultiplier / sliderTickRate / game.getTimingPointMultiplier();
|
|
|
|
int tickCount = (int) Math.ceil(hitObject.getPixelLength() / tickLengthDiv) - 1;
|
|
|
|
if (tickCount > 0) {
|
|
|
|
this.ticksT = new float[tickCount];
|
|
|
|
float tickTOffset = 1f / (tickCount + 1);
|
|
|
|
float t = tickTOffset;
|
|
|
|
for (int i = 0; i < tickCount; i++, t += tickTOffset)
|
|
|
|
ticksT[i] = t;
|
|
|
|
}
|
2016-09-27 22:23:14 +02:00
|
|
|
|
|
|
|
repeats = hitObject.getRepeatCount();
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
2015-01-16 21:44:13 +01:00
|
|
|
@Override
|
2016-09-29 21:40:42 +02:00
|
|
|
public void draw(Graphics g, int trackPosition, boolean mirror) {
|
2016-09-29 21:55:23 +02:00
|
|
|
Color orig = color;
|
|
|
|
if (mirror) {
|
2016-09-30 19:05:53 +02:00
|
|
|
color = mirrorColor;
|
2016-09-29 21:55:23 +02:00
|
|
|
}
|
|
|
|
|
2014-07-18 21:11:57 +02:00
|
|
|
int timeDiff = hitObject.getTime() - trackPosition;
|
2015-08-29 04:12:47 +02:00
|
|
|
final int approachTime = game.getApproachTime();
|
|
|
|
final int fadeInTime = game.getFadeInTime();
|
|
|
|
float scale = timeDiff / (float) approachTime;
|
2015-02-15 07:40:01 +01:00
|
|
|
float approachScale = 1 + scale * 3;
|
2015-08-29 04:12:47 +02:00
|
|
|
float fadeinScale = (timeDiff - approachTime + fadeInTime) / (float) fadeInTime;
|
2015-03-30 16:06:16 +02:00
|
|
|
float alpha = Utils.clamp(1 - fadeinScale, 0, 1);
|
2015-09-16 17:19:23 +02:00
|
|
|
float decorationsAlpha = Utils.clamp(-2.0f * fadeinScale, 0, 1);
|
2015-03-30 14:19:39 +02:00
|
|
|
boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();
|
2015-08-21 03:02:23 +02:00
|
|
|
float oldAlpha = Colors.WHITE_FADE.a;
|
|
|
|
Colors.WHITE_FADE.a = color.a = alpha;
|
2015-03-30 14:19:39 +02:00
|
|
|
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
|
|
|
|
Image hitCircle = GameImage.HITCIRCLE.getImage();
|
2015-09-05 19:53:42 +02:00
|
|
|
Vec2f endPos = curve.pointAt(1);
|
2015-02-15 07:40:01 +01:00
|
|
|
|
2016-10-04 13:01:24 +02:00
|
|
|
float curveAlpha = 1f;
|
|
|
|
if (GameMod.HIDDEN.isActive() && trackPosition > getTime()) {
|
|
|
|
curveAlpha = Math.max(0f, 1f - ((float) (trackPosition - getTime()) / (getEndTime() - getTime())) * 1.05f);
|
|
|
|
}
|
|
|
|
curveColor.a = curveAlpha;
|
|
|
|
|
2015-09-18 22:02:19 +02:00
|
|
|
float curveInterval = Options.isSliderSnaking() ? alpha : 1f;
|
2016-09-29 22:45:16 +02:00
|
|
|
curve.draw(curveColor, curveInterval);
|
2015-03-30 14:19:39 +02:00
|
|
|
color.a = alpha;
|
2015-02-15 07:40:01 +01:00
|
|
|
|
2016-09-29 21:40:42 +02:00
|
|
|
g.pushTransform();
|
|
|
|
if (mirror) {
|
|
|
|
g.rotate(x, y, -180f);
|
|
|
|
}
|
|
|
|
|
2016-09-28 22:03:45 +02:00
|
|
|
/*
|
2015-03-30 14:19:39 +02:00
|
|
|
// end circle
|
2015-09-16 17:19:23 +02:00
|
|
|
Vec2f endCircPos = curve.pointAt(curveInterval);
|
|
|
|
hitCircle.drawCentered(endCircPos.x, endCircPos.y, color);
|
|
|
|
hitCircleOverlay.drawCentered(endCircPos.x, endCircPos.y, Colors.WHITE_FADE);
|
2016-09-28 22:03:45 +02:00
|
|
|
*/
|
2015-03-30 14:19:39 +02:00
|
|
|
|
2016-09-30 23:48:02 +02:00
|
|
|
// start circle, don't draw if already clicked
|
|
|
|
if (!sliderClickedInitial) {
|
|
|
|
hitCircle.drawCentered(x, y, color);
|
|
|
|
if (!overlayAboveNumber)
|
|
|
|
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
|
|
|
|
}
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2016-09-29 21:40:42 +02:00
|
|
|
g.popTransform();
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// ticks
|
2015-03-30 16:06:16 +02:00
|
|
|
if (ticksT != null) {
|
2015-09-18 22:02:19 +02:00
|
|
|
float tickScale = 0.5f + 0.5f * AnimationEquation.OUT_BACK.calc(decorationsAlpha);
|
2015-09-16 17:19:23 +02:00
|
|
|
Image tick = GameImage.SLIDER_TICK.getImage().getScaledCopy(tickScale);
|
2014-06-30 04:17:04 +02:00
|
|
|
for (int i = 0; i < ticksT.length; i++) {
|
2015-09-05 19:53:42 +02:00
|
|
|
Vec2f c = curve.pointAt(ticksT[i]);
|
2016-10-04 13:01:24 +02:00
|
|
|
Colors.WHITE_FADE.a = Math.min(curveAlpha, decorationsAlpha);
|
2016-09-29 21:40:42 +02:00
|
|
|
g.pushTransform();
|
|
|
|
if (mirror) {
|
|
|
|
g.rotate(c.x, c.y, -180f);
|
|
|
|
}
|
2015-09-18 22:02:19 +02:00
|
|
|
tick.drawCentered(c.x, c.y, Colors.WHITE_FADE);
|
2016-09-29 21:40:42 +02:00
|
|
|
g.popTransform();
|
2015-09-16 17:19:23 +02:00
|
|
|
Colors.WHITE_FADE.a = alpha;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-29 21:40:42 +02:00
|
|
|
|
|
|
|
g.pushTransform();
|
|
|
|
if (mirror) {
|
|
|
|
g.rotate(x, y, -180f);
|
|
|
|
}
|
|
|
|
|
2015-08-08 21:12:02 +02:00
|
|
|
if (GameMod.HIDDEN.isActive()) {
|
2015-08-29 04:12:47 +02:00
|
|
|
final int hiddenDecayTime = game.getHiddenDecayTime();
|
|
|
|
final int hiddenTimeDiff = game.getHiddenTimeDiff();
|
|
|
|
if (fadeinScale <= 0f && timeDiff < hiddenTimeDiff + hiddenDecayTime) {
|
|
|
|
float hiddenAlpha = (timeDiff < hiddenTimeDiff) ? 0f : (timeDiff - hiddenTimeDiff) / (float) hiddenDecayTime;
|
|
|
|
alpha = Math.min(alpha, hiddenAlpha);
|
|
|
|
}
|
2015-08-08 21:12:02 +02:00
|
|
|
}
|
2016-09-30 23:48:02 +02:00
|
|
|
|
|
|
|
if (!sliderClickedInitial) {
|
2015-01-27 09:19:39 +01:00
|
|
|
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
2016-09-30 23:48:02 +02:00
|
|
|
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
|
|
|
|
if (overlayAboveNumber)
|
|
|
|
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
|
|
|
|
}
|
2014-12-24 08:45:43 +01:00
|
|
|
|
2016-09-29 21:40:42 +02:00
|
|
|
g.popTransform();
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// repeats
|
2015-09-16 17:19:23 +02:00
|
|
|
if (curveInterval == 1.0f) {
|
|
|
|
for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
|
|
|
|
if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
|
|
|
|
Image arrow = GameImage.REVERSEARROW.getImage();
|
2016-10-01 13:14:31 +02:00
|
|
|
//float colorLuminance = 0.299f*color.r + 0.587f*color.g + 0.114f*color.b;
|
|
|
|
//Color arrowColor = colorLuminance < 0.8f ? Color.white : Color.black;
|
|
|
|
Color arrowColor = Color.white;
|
2015-09-16 17:19:23 +02:00
|
|
|
if (tcurRepeat != currentRepeats) {
|
2015-09-18 22:02:19 +02:00
|
|
|
if (sliderTime == 0)
|
2015-09-16 17:19:23 +02:00
|
|
|
continue;
|
|
|
|
float t = Math.max(getT(trackPosition, true), 0);
|
|
|
|
arrow.setAlpha((float) (t - Math.floor(t)));
|
2015-09-18 22:02:19 +02:00
|
|
|
} else
|
|
|
|
arrow.setAlpha(Options.isSliderSnaking() ? decorationsAlpha : 1f);
|
2016-10-01 13:14:58 +02:00
|
|
|
arrow = arrow.getScaledCopy((float) (1 + 0.3d * (trackPosition % bpm) / bpm));
|
2015-09-16 17:19:23 +02:00
|
|
|
if (tcurRepeat % 2 == 0) {
|
|
|
|
// last circle
|
|
|
|
arrow.setRotation(curve.getEndAngle());
|
2015-11-21 15:30:25 +01:00
|
|
|
arrow.drawCentered(endPos.x, endPos.y, arrowColor);
|
2015-09-16 17:19:23 +02:00
|
|
|
} else {
|
|
|
|
// first circle
|
|
|
|
arrow.setRotation(curve.getStartAngle());
|
2015-11-21 15:30:25 +01:00
|
|
|
arrow.drawCentered(x, y, arrowColor);
|
2015-09-16 17:19:23 +02:00
|
|
|
}
|
2015-01-28 06:30:51 +01:00
|
|
|
}
|
2014-07-03 05:38:30 +02:00
|
|
|
}
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (timeDiff >= 0) {
|
|
|
|
// approach circle
|
2016-09-29 21:40:42 +02:00
|
|
|
g.pushTransform();
|
|
|
|
if (mirror) {
|
|
|
|
g.rotate(x, y, -180f);
|
|
|
|
}
|
2016-09-29 23:34:11 +02:00
|
|
|
if (!GameMod.HIDDEN.isActive() && Dancer.drawApproach) {
|
2015-08-08 21:12:02 +02:00
|
|
|
GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
|
2016-09-29 21:40:42 +02:00
|
|
|
}
|
|
|
|
g.popTransform();
|
2014-06-30 04:17:04 +02:00
|
|
|
} else {
|
2015-03-19 08:04:35 +01:00
|
|
|
// Since update() might not have run before drawing during a replay, the
|
|
|
|
// slider time may not have been calculated, which causes NAN numbers and flicker.
|
2015-03-16 04:05:27 +01:00
|
|
|
if (sliderTime == 0)
|
|
|
|
return;
|
2015-08-09 01:20:45 +02:00
|
|
|
|
2015-11-18 22:26:03 +01:00
|
|
|
// Don't draw follow ball if already done
|
|
|
|
if (trackPosition > hitObject.getTime() + sliderTimeTotal)
|
|
|
|
return;
|
|
|
|
|
2015-09-05 19:53:42 +02:00
|
|
|
Vec2f c = curve.pointAt(getT(trackPosition, false));
|
|
|
|
Vec2f c2 = curve.pointAt(getT(trackPosition, false) + 0.01f);
|
2015-08-09 02:15:49 +02:00
|
|
|
|
|
|
|
float t = getT(trackPosition, false);
|
|
|
|
// float dis = hitObject.getPixelLength() * HitObject.getXMultiplier() * (t - (int) t);
|
|
|
|
// Image sliderBallFrame = sliderBallImages[(int) (dis / (diameter * Math.PI) * 30) % sliderBallImages.length];
|
|
|
|
Image sliderBallFrame = sliderBallImages[(int) (t * sliderTime * 60 / 1000) % sliderBallImages.length];
|
2015-09-05 19:53:42 +02:00
|
|
|
float angle = (float) (Math.atan2(c2.y - c.y, c2.x - c.x) * 180 / Math.PI);
|
2015-08-09 02:15:49 +02:00
|
|
|
sliderBallFrame.setRotation(angle);
|
2016-09-30 20:55:10 +02:00
|
|
|
if (Options.getSkin().isAllowSliderBallTint()) {
|
|
|
|
sliderBallFrame.drawCentered(c.x, c.y, color);
|
|
|
|
} else {
|
|
|
|
sliderBallFrame.drawCentered(c.x, c.y);
|
|
|
|
}
|
2015-08-09 01:20:45 +02:00
|
|
|
|
|
|
|
// follow circle
|
2015-08-09 02:15:49 +02:00
|
|
|
if (followCircleActive) {
|
2015-09-05 19:53:42 +02:00
|
|
|
GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c.x, c.y);
|
2015-08-09 02:15:49 +02:00
|
|
|
|
2015-08-09 01:20:45 +02:00
|
|
|
// "flashlight" mod: dim the screen
|
|
|
|
if (GameMod.FLASHLIGHT.isActive()) {
|
2015-08-21 03:02:23 +02:00
|
|
|
float oldAlphaBlack = Colors.BLACK_ALPHA.a;
|
|
|
|
Colors.BLACK_ALPHA.a = 0.75f;
|
|
|
|
g.setColor(Colors.BLACK_ALPHA);
|
2015-08-09 01:20:45 +02:00
|
|
|
g.fillRect(0, 0, containerWidth, containerHeight);
|
2015-08-21 03:02:23 +02:00
|
|
|
Colors.BLACK_ALPHA.a = oldAlphaBlack;
|
2015-08-09 01:20:45 +02:00
|
|
|
}
|
2015-03-15 20:38:04 +01:00
|
|
|
}
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
2015-03-30 16:06:16 +02:00
|
|
|
|
2015-08-21 03:02:23 +02:00
|
|
|
Colors.WHITE_FADE.a = oldAlpha;
|
2016-09-29 21:55:23 +02:00
|
|
|
|
|
|
|
color = orig;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the slider hit result.
|
2015-01-27 09:19:39 +01:00
|
|
|
* @return the hit result (GameData.HIT_* constants)
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2015-01-16 09:47:37 +01:00
|
|
|
private int hitResult() {
|
2015-04-05 17:24:05 +02:00
|
|
|
/*
|
|
|
|
time scoredelta score-hit-initial-tick= unaccounted
|
|
|
|
(1/4 - 1) 396 - 300 - 30 46
|
2015-06-30 02:22:38 +02:00
|
|
|
(1+1/4 - 2) 442 - 300 - 30 - 10
|
2015-04-05 17:24:05 +02:00
|
|
|
(2+1/4 - 3) 488 - 300 - 30 - 2*10 896 (408)5x
|
2015-06-30 02:22:38 +02:00
|
|
|
(3+1/4 - 4) 534 - 300 - 30 - 3*10
|
|
|
|
(4+1/4 - 5) 580 - 300 - 30 - 4*10
|
|
|
|
(5+1/4 - 6) 626 - 300 - 30 - 5*10
|
|
|
|
(6+1/4 - 7) 672 - 300 - 30 - 6*10
|
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
difficultyMulti = 3 (+36 per combo)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
|
|
|
score =
|
2015-04-05 17:24:05 +02:00
|
|
|
(t)ticks(10) * nticks +
|
2015-06-30 02:22:38 +02:00
|
|
|
(h)hitValue
|
|
|
|
(c)combo (hitValue/25 * difficultyMultiplier*(combo-1))
|
2015-04-05 17:24:05 +02:00
|
|
|
(i)initialHit (30) +
|
|
|
|
(f)finalHit(30) +
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
s t h c i f
|
|
|
|
626 - 10*5 - 300 - 276(-216 - 30 - 30) (all)(7x)
|
|
|
|
240 - 10*5 - 100 - 90 (-60 <- 30>) (no final or initial)(6x)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
218 - 10*4 - 100 - 78 (-36 - 30) (4 tick no initial)(5x)
|
|
|
|
196 - 10*3 - 100 - 66 (-24 - 30 ) (3 tick no initial)(4x)
|
|
|
|
112 - 10*2 - 50 - 42 (-12 - 30 ) (2 tick no initial)(3x)
|
|
|
|
96 - 10 - 50 - 36 ( -6 - 30 ) (1 tick no initial)(2x)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
206 - 10*4 - 100 - 66 (-36 - 30 ) (4 tick no initial)(4x)
|
|
|
|
184 - 10*3 - 100 - 54 (-24 - 30 ) (3 tick no initial)(3x)
|
|
|
|
90 - 10 - 50 - 30 ( - 30 ) (1 tick no initial)(0x)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
194 - 10*4 - 100 - 54 (-24 - 30 ) (4 tick no initial)(3x)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
170 - 10*4 - 100 - 30 ( - 30 ) (4 tick no final)(0x)
|
|
|
|
160 - 10*3 - 100 - 30 ( - 30 ) (3 tick no final)(0x)
|
|
|
|
100 - 10*2 - 50 - 30 ( - 30 ) (2 tick no final)(0x)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
198 - 10*5 - 100 - 48 (-36 ) (no initial and final)(5x)
|
|
|
|
110 - 50 - ( - 30 - 30 ) (final and initial no tick)(0x)
|
|
|
|
80 - 50 - ( <- 30> ) (only final or initial)(0x)
|
2015-06-30 02:22:38 +02:00
|
|
|
|
2015-04-05 17:24:05 +02:00
|
|
|
140 - 10*4 - 100 - 0 (4 ticks only)(0x)
|
|
|
|
80 - 10*3 - 50 - 0 (3 tick only)(0x)
|
|
|
|
70 - 10*2 - 50 - 0 (2 tick only)(0x)
|
|
|
|
60 - 10 - 50 - 0 (1 tick only)(0x)
|
|
|
|
*/
|
2014-06-30 04:17:04 +02:00
|
|
|
float tickRatio = (float) ticksHit / tickIntervals;
|
|
|
|
|
|
|
|
int result;
|
|
|
|
if (tickRatio >= 1.0f)
|
2015-01-27 09:19:39 +01:00
|
|
|
result = GameData.HIT_300;
|
2014-06-30 04:17:04 +02:00
|
|
|
else if (tickRatio >= 0.5f)
|
2015-01-27 09:19:39 +01:00
|
|
|
result = GameData.HIT_100;
|
2014-06-30 04:17:04 +02:00
|
|
|
else if (tickRatio > 0f)
|
2015-01-27 09:19:39 +01:00
|
|
|
result = GameData.HIT_50;
|
2014-06-30 04:17:04 +02:00
|
|
|
else
|
2015-01-27 09:19:39 +01:00
|
|
|
result = GameData.HIT_MISS;
|
2015-06-22 01:45:38 +02:00
|
|
|
|
2015-04-08 08:05:12 +02:00
|
|
|
float cx, cy;
|
|
|
|
HitObjectType type;
|
2015-01-30 02:36:23 +01:00
|
|
|
if (currentRepeats % 2 == 0) { // last circle
|
2015-09-05 19:53:42 +02:00
|
|
|
Vec2f lastPos = curve.pointAt(1);
|
|
|
|
cx = lastPos.x;
|
|
|
|
cy = lastPos.y;
|
2015-04-08 08:05:12 +02:00
|
|
|
type = HitObjectType.SLIDER_LAST;
|
2015-01-30 02:36:23 +01:00
|
|
|
} else { // first circle
|
2015-04-08 08:05:12 +02:00
|
|
|
cx = x;
|
|
|
|
cy = y;
|
|
|
|
type = HitObjectType.SLIDER_FIRST;
|
2015-01-30 02:36:23 +01:00
|
|
|
}
|
2015-04-07 07:24:09 +02:00
|
|
|
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
2015-06-30 02:22:38 +02:00
|
|
|
cx, cy, color, comboEnd, hitObject, type, sliderHeldToEnd,
|
|
|
|
currentRepeats + 1, curve, sliderHeldToEnd);
|
2016-10-01 12:39:52 +02:00
|
|
|
if (Dancer.mirror && GameMod.AUTO.isActive()) {
|
2016-09-30 23:56:07 +02:00
|
|
|
float[] m = Utils.mirrorPoint(cx, cy);
|
2016-09-30 23:53:48 +02:00
|
|
|
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
2016-09-30 23:56:07 +02:00
|
|
|
m[0], m[1], mirrorColor, comboEnd, hitObject, type, sliderHeldToEnd,
|
2016-10-01 00:25:55 +02:00
|
|
|
currentRepeats + 1, curve, sliderHeldToEnd, false);
|
2016-09-30 23:53:48 +02:00
|
|
|
}
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-01-16 21:44:13 +01:00
|
|
|
@Override
|
2015-03-15 19:15:34 +01:00
|
|
|
public boolean mousePressed(int x, int y, int trackPosition) {
|
2015-02-21 23:12:18 +01:00
|
|
|
if (sliderClickedInitial) // first circle already processed
|
2014-06-30 04:17:04 +02:00
|
|
|
return false;
|
|
|
|
|
2015-03-13 01:12:43 +01:00
|
|
|
double distance = Math.hypot(this.x - x, this.y - y);
|
2015-04-05 17:24:05 +02:00
|
|
|
if (distance < diameter / 2) {
|
2014-07-18 21:11:57 +02:00
|
|
|
int timeDiff = Math.abs(trackPosition - hitObject.getTime());
|
2014-06-30 04:17:04 +02:00
|
|
|
int[] hitResultOffset = game.getHitResultOffsets();
|
2015-01-16 21:44:13 +01:00
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
int result = -1;
|
2015-01-27 09:19:39 +01:00
|
|
|
if (timeDiff < hitResultOffset[GameData.HIT_50]) {
|
|
|
|
result = GameData.HIT_SLIDER30;
|
2014-06-30 04:17:04 +02:00
|
|
|
ticksHit++;
|
2015-01-27 09:19:39 +01:00
|
|
|
} else if (timeDiff < hitResultOffset[GameData.HIT_MISS])
|
|
|
|
result = GameData.HIT_MISS;
|
2014-06-30 04:17:04 +02:00
|
|
|
//else not a hit
|
|
|
|
|
|
|
|
if (result > -1) {
|
2015-02-15 04:15:41 +01:00
|
|
|
data.addHitError(hitObject.getTime(), x,y,trackPosition - hitObject.getTime());
|
2015-02-21 23:12:18 +01:00
|
|
|
sliderClickedInitial = true;
|
2015-03-13 01:12:43 +01:00
|
|
|
data.sliderTickResult(hitObject.getTime(), result, this.x, this.y, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-16 21:44:13 +01:00
|
|
|
@Override
|
2015-03-15 19:15:34 +01:00
|
|
|
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition) {
|
2014-07-18 21:11:57 +02:00
|
|
|
int repeatCount = hitObject.getRepeatCount();
|
2015-01-16 21:44:13 +01:00
|
|
|
int[] hitResultOffset = game.getHitResultOffsets();
|
2014-07-16 22:01:36 +02:00
|
|
|
boolean isAutoMod = GameMod.AUTO.isActive();
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-02-21 23:12:18 +01:00
|
|
|
if (!sliderClickedInitial) {
|
2014-07-18 21:11:57 +02:00
|
|
|
int time = hitObject.getTime();
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// start circle time passed
|
2015-01-27 09:19:39 +01:00
|
|
|
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
|
2015-02-21 23:12:18 +01:00
|
|
|
sliderClickedInitial = true;
|
2014-06-30 04:17:04 +02:00
|
|
|
if (isAutoMod) { // "auto" mod: catch any missed notes due to lag
|
|
|
|
ticksHit++;
|
2015-03-13 01:12:43 +01:00
|
|
|
data.sliderTickResult(time, GameData.HIT_SLIDER30, x, y, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
} else
|
2015-03-13 01:12:43 +01:00
|
|
|
data.sliderTickResult(time, GameData.HIT_MISS, x, y, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// "auto" mod: send a perfect hit result
|
|
|
|
else if (isAutoMod) {
|
2015-01-27 09:19:39 +01:00
|
|
|
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
|
2014-06-30 04:17:04 +02:00
|
|
|
ticksHit++;
|
2015-02-21 23:12:18 +01:00
|
|
|
sliderClickedInitial = true;
|
2015-03-13 01:12:43 +01:00
|
|
|
data.sliderTickResult(time, GameData.HIT_SLIDER30, x, y, hitObject, currentRepeats);
|
2016-09-30 23:48:02 +02:00
|
|
|
data.sendInitialSliderResult(time, x, y, color, mirrorColor);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
2015-03-06 06:25:48 +01:00
|
|
|
|
|
|
|
// "relax" mod: click automatically
|
|
|
|
else if (GameMod.RELAX.isActive() && trackPosition >= time)
|
2015-03-15 19:15:34 +01:00
|
|
|
mousePressed(mouseX, mouseY, trackPosition);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// end of slider
|
2015-04-05 17:24:05 +02:00
|
|
|
if (trackPosition > hitObject.getTime() + sliderTimeTotal) {
|
2014-06-30 04:17:04 +02:00
|
|
|
tickIntervals++;
|
|
|
|
|
|
|
|
// check if cursor pressed and within end circle
|
2015-03-09 23:32:43 +01:00
|
|
|
if (keyPressed || GameMod.RELAX.isActive()) {
|
2015-09-05 19:53:42 +02:00
|
|
|
Vec2f c = curve.pointAt(getT(trackPosition, false));
|
|
|
|
double distance = Math.hypot(c.x - mouseX, c.y - mouseY);
|
2015-06-22 01:45:38 +02:00
|
|
|
if (distance < followRadius)
|
2015-06-30 02:22:38 +02:00
|
|
|
sliderHeldToEnd = true;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
2014-07-06 03:00:52 +02:00
|
|
|
|
2015-02-21 23:12:18 +01:00
|
|
|
// final circle hit
|
2015-06-30 02:22:38 +02:00
|
|
|
if (sliderHeldToEnd)
|
2015-02-21 23:12:18 +01:00
|
|
|
ticksHit++;
|
|
|
|
|
|
|
|
// "auto" mod: always send a perfect hit result
|
|
|
|
if (isAutoMod)
|
|
|
|
ticksHit = tickIntervals;
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// calculate and send slider result
|
|
|
|
hitResult();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// repeats
|
|
|
|
boolean isNewRepeat = false;
|
2014-07-18 21:11:57 +02:00
|
|
|
if (repeatCount - 1 > currentRepeats) {
|
2014-06-30 04:17:04 +02:00
|
|
|
float t = getT(trackPosition, true);
|
|
|
|
if (Math.floor(t) > currentRepeats) {
|
|
|
|
currentRepeats++;
|
|
|
|
tickIntervals++;
|
|
|
|
isNewRepeat = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ticks
|
|
|
|
boolean isNewTick = false;
|
|
|
|
if (ticksT != null &&
|
2014-07-18 21:11:57 +02:00
|
|
|
tickIntervals < (ticksT.length * (currentRepeats + 1)) + repeatCount &&
|
|
|
|
tickIntervals < (ticksT.length * repeatCount) + repeatCount) {
|
2014-06-30 04:17:04 +02:00
|
|
|
float t = getT(trackPosition, true);
|
|
|
|
if (t - Math.floor(t) >= ticksT[tickIndex]) {
|
|
|
|
tickIntervals++;
|
|
|
|
tickIndex = (tickIndex + 1) % ticksT.length;
|
|
|
|
isNewTick = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// holding slider...
|
2015-09-05 19:53:42 +02:00
|
|
|
Vec2f c = curve.pointAt(getT(trackPosition, false));
|
|
|
|
double distance = Math.hypot(c.x - mouseX, c.y - mouseY);
|
2015-04-05 17:24:05 +02:00
|
|
|
if (((keyPressed || GameMod.RELAX.isActive()) && distance < followRadius) || isAutoMod) {
|
2014-06-30 04:17:04 +02:00
|
|
|
// mouse pressed and within follow circle
|
|
|
|
followCircleActive = true;
|
|
|
|
|
|
|
|
// held during new repeat
|
|
|
|
if (isNewRepeat) {
|
|
|
|
ticksHit++;
|
2015-03-13 01:12:43 +01:00
|
|
|
if (currentRepeats % 2 > 0) { // last circle
|
|
|
|
int lastIndex = hitObject.getSliderX().length;
|
2015-01-27 09:19:39 +01:00
|
|
|
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
|
2015-03-13 01:12:43 +01:00
|
|
|
curve.getX(lastIndex), curve.getY(lastIndex), hitObject, currentRepeats);
|
|
|
|
} else // first circle
|
2015-01-27 09:19:39 +01:00
|
|
|
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
|
2015-09-05 19:53:42 +02:00
|
|
|
c.x, c.y, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// held during new tick
|
|
|
|
if (isNewTick) {
|
|
|
|
ticksHit++;
|
2015-01-27 09:19:39 +01:00
|
|
|
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER10,
|
2015-09-05 19:53:42 +02:00
|
|
|
c.x, c.y, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
2015-02-21 23:12:18 +01:00
|
|
|
|
|
|
|
// held near end of slider
|
2015-06-30 02:22:38 +02:00
|
|
|
if (!sliderHeldToEnd && trackPosition > hitObject.getTime() + sliderTimeTotal - hitResultOffset[GameData.HIT_300])
|
|
|
|
sliderHeldToEnd = true;
|
2014-06-30 04:17:04 +02:00
|
|
|
} else {
|
|
|
|
followCircleActive = false;
|
|
|
|
|
|
|
|
if (isNewRepeat)
|
2015-03-01 17:06:46 +01:00
|
|
|
data.sliderTickResult(trackPosition, GameData.HIT_MISS, 0, 0, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
if (isNewTick)
|
2015-03-01 17:06:46 +01:00
|
|
|
data.sliderTickResult(trackPosition, GameData.HIT_MISS, 0, 0, hitObject, currentRepeats);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-28 13:11:43 +01:00
|
|
|
@Override
|
|
|
|
public void updatePosition() {
|
|
|
|
this.x = hitObject.getScaledX();
|
|
|
|
this.y = hitObject.getScaledY();
|
2015-09-02 17:51:52 +02:00
|
|
|
this.curve = hitObject.getSliderCurve(true);
|
2015-03-28 13:11:43 +01:00
|
|
|
}
|
|
|
|
|
2015-03-17 19:48:13 +01:00
|
|
|
@Override
|
2015-09-05 19:53:42 +02:00
|
|
|
public Vec2f getPointAt(int trackPosition) {
|
2015-03-17 19:48:13 +01:00
|
|
|
if (trackPosition <= hitObject.getTime())
|
2015-09-05 19:53:42 +02:00
|
|
|
return new Vec2f(x, y);
|
2015-03-17 19:48:13 +01:00
|
|
|
else if (trackPosition >= hitObject.getTime() + sliderTimeTotal) {
|
|
|
|
if (hitObject.getRepeatCount() % 2 == 0)
|
2015-09-05 19:53:42 +02:00
|
|
|
return new Vec2f(x, y);
|
2015-03-31 05:58:11 +02:00
|
|
|
else
|
|
|
|
return curve.pointAt(1);
|
2015-03-17 19:48:13 +01:00
|
|
|
} else
|
|
|
|
return curve.pointAt(getT(trackPosition, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getEndTime() { return hitObject.getTime() + (int) sliderTimeTotal; }
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the t value based on the given track position.
|
|
|
|
* @param trackPosition the current track position
|
|
|
|
* @param raw if false, ensures that the value lies within [0, 1] by looping repeats
|
|
|
|
* @return the t value: raw [0, repeats] or looped [0, 1]
|
|
|
|
*/
|
2015-01-16 09:47:37 +01:00
|
|
|
private float getT(int trackPosition, boolean raw) {
|
2014-07-18 21:11:57 +02:00
|
|
|
float t = (trackPosition - hitObject.getTime()) / sliderTime;
|
2014-06-30 04:17:04 +02:00
|
|
|
if (raw)
|
|
|
|
return t;
|
|
|
|
else {
|
|
|
|
float floor = (float) Math.floor(t);
|
|
|
|
return (floor % 2 == 0) ? t - floor : floor + 1 - t;
|
|
|
|
}
|
|
|
|
}
|
2015-04-05 17:24:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void reset() {
|
|
|
|
sliderClickedInitial = false;
|
2015-06-30 02:22:38 +02:00
|
|
|
sliderHeldToEnd = false;
|
2015-04-05 17:24:05 +02:00
|
|
|
followCircleActive = false;
|
|
|
|
currentRepeats = 0;
|
|
|
|
tickIndex = 0;
|
|
|
|
ticksHit = 0;
|
|
|
|
tickIntervals = 1;
|
|
|
|
}
|
2016-09-27 18:26:53 +02:00
|
|
|
|
2016-09-27 22:23:14 +02:00
|
|
|
public Curve getCurve() {
|
|
|
|
return curve;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRepeats() {
|
|
|
|
return repeats;
|
|
|
|
}
|
|
|
|
|
2016-09-27 18:26:53 +02:00
|
|
|
@Override
|
|
|
|
public boolean isCircle() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSlider() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSpinner() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-30 19:38:02 +02:00
|
|
|
@Override
|
|
|
|
public Color getColor() {
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Color getMirroredColor() {
|
|
|
|
return mirrorColor;
|
|
|
|
}
|
|
|
|
|
2016-11-12 18:25:44 +01:00
|
|
|
public Circle[] getTickPositionCircles() {
|
|
|
|
float tickLengthDiv = 100f * sliderMultiplier / sliderTickRate / (game.getBeatLength() / game.getBeatLengthBase());
|
|
|
|
int tickCount = (int) Math.ceil(pixelLength / tickLengthDiv) - 1;
|
|
|
|
Circle[] ticks = new Circle[1 + ( tickCount + 1 ) * repeats];
|
|
|
|
Vec2f pos;
|
|
|
|
pos = getPointAt( getTime() );
|
|
|
|
pos.set( HitObject.unscaleX( pos.x ), HitObject.unscaleY( pos.y ) );
|
|
|
|
ticks[0] = new Circle(pos.x, pos.y, getTime() );
|
|
|
|
float tickTOffset = 1f / (tickCount + 1) / repeats;
|
|
|
|
float t = tickTOffset;
|
|
|
|
for( int i = 0; i < (tickCount + 1) * repeats; i++, t += tickTOffset ) {
|
|
|
|
pos = getPointAt( getTime() + (int) (t * sliderTimeTotal ) );
|
|
|
|
pos.set( HitObject.unscaleX( pos.x ), HitObject.unscaleY( pos.y ) );
|
|
|
|
ticks[1 + i] = new Circle(pos.x, pos.y, getTime() + (int) (t * sliderTimeTotal));
|
|
|
|
}
|
|
|
|
|
|
|
|
for(Circle c : ticks) {
|
|
|
|
c.updatePosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ticks;
|
|
|
|
}
|
|
|
|
|
2015-03-18 04:47:33 +01:00
|
|
|
}
|