diff --git a/src/itdelatrisu/opsu/GameData.java b/src/itdelatrisu/opsu/GameData.java index 63c01a61..b5b355c0 100644 --- a/src/itdelatrisu/opsu/GameData.java +++ b/src/itdelatrisu/opsu/GameData.java @@ -1201,13 +1201,8 @@ public class GameData { if (!Dancer.mirror) { return; } - 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); - x = (float) (Options.width / 2d + Math.cos(ang) * d); - y = (float) (Options.height / 2d + Math.sin(ang) * d); - hitResultList.add(new HitObjectResult(time, HIT_SLIDER_INITIAL, x, y, mirrorcolor, null, null, true, false)); + float[] m = Utils.mirrorPoint(x, y); + hitResultList.add(new HitObjectResult(time, HIT_SLIDER_INITIAL, m[0], m[1], mirrorcolor, null, null, true, false)); } /** diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java index 801563f2..c1b755e8 100644 --- a/src/itdelatrisu/opsu/Utils.java +++ b/src/itdelatrisu/opsu/Utils.java @@ -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) + }; + } + } diff --git a/src/itdelatrisu/opsu/objects/Circle.java b/src/itdelatrisu/opsu/objects/Circle.java index d0dad808..28798501 100644 --- a/src/itdelatrisu/opsu/objects/Circle.java +++ b/src/itdelatrisu/opsu/objects/Circle.java @@ -190,13 +190,8 @@ public class Circle extends GameObject { 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); if (Dancer.mirror) { - 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); - float nx = (float) (Options.width / 2d + Math.cos(ang) * d); - float ny = (float) (Options.height / 2d + Math.sin(ang) * d); - data.hitResult(time, GameData.HIT_300, nx, ny, mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); + 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); } } @@ -210,13 +205,8 @@ public class Circle extends GameObject { 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); if (Dancer.mirror) { - 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); - float nx = (float) (Options.width / 2d + Math.cos(ang) * d); - float ny = (float) (Options.height / 2d + Math.sin(ang) * d); - data.hitResult(time, GameData.HIT_300, nx, ny, mirrorColor, comboEnd, hitObject, HitObjectType.CIRCLE, true, 0, null, false); + 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; } diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index 8112ca26..8608c5b1 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -430,14 +430,9 @@ public class Slider extends GameObject { cx, cy, color, comboEnd, hitObject, type, sliderHeldToEnd, currentRepeats + 1, curve, sliderHeldToEnd); if (Dancer.mirror) { - double dx = cx - Options.width / 2d; - double dy = cy - Options.height / 2d; - double ang = Math.atan2(dy, dx); - double d = -Math.sqrt(dx * dx + dy * dy); - float nx = (float) (Options.width / 2d + Math.cos(ang) * d); - float ny = (float) (Options.height / 2d + Math.sin(ang) * d); + float[] m = Utils.mirrorPoint(cx, cy); data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result, - nx, ny, mirrorColor, comboEnd, hitObject, type, sliderHeldToEnd, + m[0], m[1], mirrorColor, comboEnd, hitObject, type, sliderHeldToEnd, currentRepeats + 1, curve, sliderHeldToEnd); }