Merge branch 'hitresults'

This commit is contained in:
yugecin 2016-09-30 23:56:15 +02:00
commit fcd9efc7f7
4 changed files with 67 additions and 12 deletions

View File

@ -43,6 +43,7 @@ import org.newdawn.slick.Animation;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image; import org.newdawn.slick.Image;
import yugecin.opsudance.Dancer;
/** /**
* Holds game data and renders all related elements. * Holds game data and renders all related elements.
@ -150,7 +151,8 @@ public class GameData {
HIT_300G = 6, // Geki HIT_300G = 6, // Geki
HIT_SLIDER10 = 7, HIT_SLIDER10 = 7,
HIT_SLIDER30 = 8, HIT_SLIDER30 = 8,
HIT_MAX = 9; // not a hit result HIT_MAX = 9, // not a hit result
HIT_SLIDER_INITIAL = 10;
/** Hit result-related images (indexed by HIT_* constants). */ /** Hit result-related images (indexed by HIT_* constants). */
private Image[] hitResults; private Image[] hitResults;
@ -928,6 +930,19 @@ public class GameData {
} }
} }
if (hitResult.result == HIT_SLIDER_INITIAL) {
float progress = AnimationEquation.OUT_CUBIC.calc(
(float) Utils.clamp(trackPosition - hitResult.time, 0, HITCIRCLE_FADE_TIME) / HITCIRCLE_FADE_TIME);
float scale = (!hitResult.expand) ? 1f : 1f + (HITCIRCLE_ANIM_SCALE - 1f) * progress;
float alpha = 1f - progress;
Image scaledHitCircle = GameImage.HITCIRCLE.getImage().getScaledCopy(scale);
Image scaledHitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage().getScaledCopy(scale);
scaledHitCircle.setAlpha(alpha);
scaledHitCircleOverlay.setAlpha(alpha);
scaledHitCircle.drawCentered(hitResult.x, hitResult.y, hitResult.color);
scaledHitCircleOverlay.drawCentered(hitResult.x, hitResult.y);
}
// hit result // hit result
if (!hitResult.hideResult && ( if (!hitResult.hideResult && (
hitResult.hitResultType == HitObjectType.CIRCLE || hitResult.hitResultType == HitObjectType.CIRCLE ||
@ -1181,6 +1196,15 @@ public class GameData {
health = 0f; health = 0f;
} }
public void sendInitialSliderResult(int time, float x, float y, Color color, Color mirrorcolor) {
hitResultList.add(new HitObjectResult(time, HIT_SLIDER_INITIAL, x, y, color, null, null, true, false));
if (!Dancer.mirror) {
return;
}
float[] m = Utils.mirrorPoint(x, y);
hitResultList.add(new HitObjectResult(time, HIT_SLIDER_INITIAL, m[0], m[1], mirrorcolor, null, null, true, false));
}
/** /**
* Handles a slider tick result. * Handles a slider tick result.
* @param time the tick start time * @param time the tick start time
@ -1383,6 +1407,7 @@ public class GameData {
boolean hideResult = (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) && !Options.isPerfectHitBurstEnabled(); boolean hideResult = (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) && !Options.isPerfectHitBurstEnabled();
hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult));
/*
// sliders: add the other curve endpoint for the hit animation // sliders: add the other curve endpoint for the hit animation
if (curve != null) { if (curve != null) {
boolean isFirst = (hitResultType == HitObjectType.SLIDER_FIRST); boolean isFirst = (hitResultType == HitObjectType.SLIDER_FIRST);
@ -1390,6 +1415,7 @@ public class GameData {
HitObjectType type = (isFirst) ? HitObjectType.SLIDER_LAST : HitObjectType.SLIDER_FIRST; HitObjectType type = (isFirst) ? HitObjectType.SLIDER_LAST : HitObjectType.SLIDER_FIRST;
hitResultList.add(new HitObjectResult(time, hitResult, p.x, p.y, color, type, null, expand, hideResult)); hitResultList.add(new HitObjectResult(time, hitResult, p.x, p.y, color, type, null, expand, hideResult));
} }
*/
} }
/** /**

View File

@ -590,4 +590,15 @@ public class Utils {
} }
*/ */
public static float[] mirrorPoint(float x, float y) {
double dx = x - Options.width / 2d;
double dy = y - Options.height / 2d;
double ang = Math.atan2(dy, dx);
double d = -Math.sqrt(dx * dx + dy * dy);
return new float[]{
(float) (Options.width / 2d + Math.cos(ang) * d),
(float) (Options.height / 2d + Math.sin(ang) * d)
};
}
} }

View File

@ -187,8 +187,13 @@ public class Circle extends GameObject {
boolean isAutoMod = GameMod.AUTO.isActive(); boolean isAutoMod = GameMod.AUTO.isActive();
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) { if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
if (isAutoMod) // "auto" mod: catch any missed notes due to lag if (isAutoMod) {// "auto" mod: catch any missed notes due to lag
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
if (Dancer.mirror) {
float[] m = Utils.mirrorPoint(x, y);
data.hitResult(time, GameData.HIT_300, m[0], m[1], mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
}
}
else // no more points can be scored, so send a miss else // no more points can be scored, so send a miss
data.hitResult(trackPosition, GameData.HIT_MISS, x, y, null, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); data.hitResult(trackPosition, GameData.HIT_MISS, x, y, null, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
@ -199,6 +204,10 @@ public class Circle extends GameObject {
else if (isAutoMod) { else if (isAutoMod) {
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) { if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
if (Dancer.mirror) {
float[] m = Utils.mirrorPoint(x, y);
data.hitResult(time, GameData.HIT_300, m[0], m[1], mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false);
}
return true; return true;
} }
} }

View File

@ -219,10 +219,12 @@ public class Slider extends GameObject {
hitCircleOverlay.drawCentered(endCircPos.x, endCircPos.y, Colors.WHITE_FADE); hitCircleOverlay.drawCentered(endCircPos.x, endCircPos.y, Colors.WHITE_FADE);
*/ */
// start circle // start circle, don't draw if already clicked
if (!sliderClickedInitial) {
hitCircle.drawCentered(x, y, color); hitCircle.drawCentered(x, y, color);
if (!overlayAboveNumber) if (!overlayAboveNumber)
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE); hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
}
g.popTransform(); g.popTransform();
@ -256,13 +258,13 @@ public class Slider extends GameObject {
alpha = Math.min(alpha, hiddenAlpha); alpha = Math.min(alpha, hiddenAlpha);
} }
} }
if (sliderClickedInitial)
; // don't draw current combo number if already clicked if (!sliderClickedInitial) {
else
data.drawSymbolNumber(hitObject.getComboNumber(), x, y, data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha); hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(), alpha);
if (overlayAboveNumber) if (overlayAboveNumber)
hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE); hitCircleOverlay.drawCentered(x, y, Colors.WHITE_FADE);
}
g.popTransform(); g.popTransform();
@ -427,6 +429,12 @@ public class Slider extends GameObject {
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result, data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
cx, cy, color, comboEnd, hitObject, type, sliderHeldToEnd, cx, cy, color, comboEnd, hitObject, type, sliderHeldToEnd,
currentRepeats + 1, curve, sliderHeldToEnd); currentRepeats + 1, curve, sliderHeldToEnd);
if (Dancer.mirror) {
float[] m = Utils.mirrorPoint(cx, cy);
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
m[0], m[1], mirrorColor, comboEnd, hitObject, type, sliderHeldToEnd,
currentRepeats + 1, curve, sliderHeldToEnd);
}
return result; return result;
} }
@ -484,6 +492,7 @@ public class Slider extends GameObject {
ticksHit++; ticksHit++;
sliderClickedInitial = true; sliderClickedInitial = true;
data.sliderTickResult(time, GameData.HIT_SLIDER30, x, y, hitObject, currentRepeats); data.sliderTickResult(time, GameData.HIT_SLIDER30, x, y, hitObject, currentRepeats);
data.sendInitialSliderResult(time, x, y, color, mirrorColor);
} }
} }