Store raw hit object coordinates instead of scaled ones.

Fixes a bug where a resolution change (by restarting through the app) wouldn't re-scale hit object coordinates.  Scaled coordinates are now stored in HitObject fields.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-03-12 20:12:43 -04:00
parent 3bd9bbdafd
commit 49c85b3b08
7 changed files with 104 additions and 64 deletions

View File

@@ -37,6 +37,9 @@ public class Circle implements HitObject {
/** The associated OsuHitObject. */
private OsuHitObject hitObject;
/** The scaled starting x, y coordinates. */
private float x, y;
/** The associated Game object. */
private Game game;
@@ -72,6 +75,8 @@ public class Circle implements HitObject {
*/
public Circle(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
this.hitObject = hitObject;
this.x = hitObject.getScaledX();
this.y = hitObject.getScaledY();
this.game = game;
this.data = data;
this.color = color;
@@ -84,7 +89,6 @@ public class Circle implements HitObject {
if (timeDiff >= 0) {
float oldAlpha = color.a;
float x = hitObject.getX(), y = hitObject.getY();
float scale = timeDiff / (float)game.getApproachTime();
float approachScale = 1 + scale * 3;
@@ -129,7 +133,7 @@ public class Circle implements HitObject {
@Override
public boolean mousePressed(int x, int y) {
double distance = Math.hypot(hitObject.getX() - x, hitObject.getY() - y);
double distance = Math.hypot(this.x - x, this.y - y);
int circleRadius = GameImage.HITCIRCLE.getImage().getWidth() / 2;
if (distance < circleRadius) {
int trackPosition = MusicController.getPosition();
@@ -138,11 +142,7 @@ public class Circle implements HitObject {
if (result > -1) {
data.addHitError(hitObject.getTime(), x, y, timeDiff);
data.hitResult(
hitObject.getTime(), result,
hitObject.getX(), hitObject.getY(),
color, comboEnd, hitObject, 0
);
data.hitResult(hitObject.getTime(), result, this.x, this.y, color, comboEnd, hitObject, 0);
return true;
}
}
@@ -152,7 +152,6 @@ public class Circle implements HitObject {
@Override
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed) {
int time = hitObject.getTime();
float x = hitObject.getX(), y = hitObject.getY();
int trackPosition = MusicController.getPosition();
int[] hitResultOffset = game.getHitResultOffsets();