Merge remote-tracking branch 'org/master' into ReplayTest

Conflicts:
	src/itdelatrisu/opsu/objects/HitObject.java
	src/itdelatrisu/opsu/states/Game.java
This commit is contained in:
fd
2015-03-17 23:47:33 -04:00
17 changed files with 553 additions and 198 deletions

View File

@@ -178,4 +178,10 @@ public class Circle implements HitObject {
return false;
}
}
@Override
public float[] getPointAt(int trackPosition) { return new float[] { x, y }; }
@Override
public int getEndTime() { return hitObject.getTime(); }
}

View File

@@ -51,4 +51,17 @@ public interface HitObject {
* @return true if a hit result was processed
*/
public boolean mousePressed(int x, int y, int trackPosition);
/**
* Returns the coordinates of the hit object at a given track position.
* @param trackPosition the track position
* @return the [x,y] coordinates
*/
public float[] getPointAt(int trackPosition);
/**
* Returns the end time of the hit object.
* @return the end time, in milliseconds
*/
public int getEndTime();
}

View File

@@ -92,6 +92,9 @@ public class Slider implements HitObject {
/** Number of ticks hit and tick intervals so far. */
private int ticksHit = 0, tickIntervals = 1;
/** Container dimensions. */
private static int containerWidth, containerHeight;
/**
* Initializes the Slider data type with images and dimensions.
* @param container the game container
@@ -99,6 +102,9 @@ public class Slider implements HitObject {
* @param osu the associated OsuFile object
*/
public static void init(GameContainer container, float circleSize, OsuFile osu) {
containerWidth = container.getWidth();
containerHeight = container.getHeight();
int diameter = (int) (104 - (circleSize * 8));
diameter = (int) (diameter * OsuHitObject.getXMultiplier()); // convert from Osupixels (640x480)
@@ -188,7 +194,7 @@ public class Slider implements HitObject {
color.a = oldAlpha;
// repeats
for(int tcurRepeat = currentRepeats; tcurRepeat<=currentRepeats+1; tcurRepeat++){
for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
Image arrow = GameImage.REVERSEARROW.getImage();
if (tcurRepeat != currentRepeats) {
@@ -233,8 +239,18 @@ public class Slider implements HitObject {
sliderBallFrame.drawCentered(c[0], c[1]);
// follow circle
if (followCircleActive)
if (followCircleActive) {
GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c[0], c[1]);
// "flashlight" mod: dim the screen
if (GameMod.FLASHLIGHT.isActive()) {
float oldAlphaBlack = Utils.COLOR_BLACK_ALPHA.a;
Utils.COLOR_BLACK_ALPHA.a = 0.75f;
g.setColor(Utils.COLOR_BLACK_ALPHA);
g.fillRect(0, 0, containerWidth, containerHeight);
Utils.COLOR_BLACK_ALPHA.a = oldAlphaBlack;
}
}
}
}
@@ -441,6 +457,24 @@ public class Slider implements HitObject {
return false;
}
@Override
public float[] getPointAt(int trackPosition) {
if (trackPosition <= hitObject.getTime())
return new float[] { x, y };
else if (trackPosition >= hitObject.getTime() + sliderTimeTotal) {
if (hitObject.getRepeatCount() % 2 == 0)
return new float[] { x, y };
else {
int lastIndex = hitObject.getSliderX().length;
return new float[] { curve.getX(lastIndex), curve.getY(lastIndex) };
}
} else
return curve.pointAt(getT(trackPosition, false));
}
@Override
public int getEndTime() { return hitObject.getTime() + (int) sliderTimeTotal; }
/**
* Returns the t value based on the given track position.
* @param trackPosition the current track position
@@ -456,4 +490,4 @@ public class Slider implements HitObject {
return (floor % 2 == 0) ? t - floor : floor + 1 - t;
}
}
}
}

View File

@@ -50,8 +50,15 @@ public class Spinner implements HitObject {
/** The amount of time, in milliseconds, to fade in the spinner. */
private static final int FADE_IN_TIME = 500;
/** Angle mod multipliers: "auto" (477rpm), "spun out" (287rpm) */
private static final float
AUTO_MULTIPLIER = 1 / 20f, // angle = 477/60f * delta/1000f * TWO_PI;
SPUN_OUT_MULTIPLIER = 1 / 33.25f; // angle = 287/60f * delta/1000f * TWO_PI;
/** PI constants. */
private static final float TWO_PI = (float) (Math.PI * 2);
private static final float
TWO_PI = (float) (Math.PI * 2),
HALF_PI = (float) (Math.PI / 2);
/** The associated OsuHitObject. */
private OsuHitObject hitObject;
@@ -174,8 +181,7 @@ public class Spinner implements HitObject {
// TODO: verify ratios
int result;
float ratio = rotations / rotationsNeeded;
if (ratio >= 1.0f ||
GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) {
if (ratio >= 1.0f || GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive() || GameMod.SPUN_OUT.isActive()) {
result = GameData.HIT_300;
SoundController.playSound(SoundEffect.SPINNEROSU);
} else if (ratio >= 0.9f)
@@ -210,14 +216,12 @@ public class Spinner implements HitObject {
// http://osu.ppy.sh/wiki/FAQ#Spinners
float angle;
if (GameMod.AUTO.isActive()) {
// "auto" mod (fast: 477rpm)
lastAngle = 0;
angle = delta / 20f; // angle = 477/60f * delta/1000f * TWO_PI;
angle = delta * AUTO_MULTIPLIER;
isSpinning = true;
} else if (GameMod.SPUN_OUT.isActive()) {
// "spun out" mod (slow: 287rpm)
} else if (GameMod.SPUN_OUT.isActive() || GameMod.AUTOPILOT.isActive()) {
lastAngle = 0;
angle = delta / 33.25f; // angle = 287/60f * delta/1000f * TWO_PI;
angle = delta * SPUN_OUT_MULTIPLIER;
isSpinning = true;
} else {
angle = (float) Math.atan2(mouseY - (height / 2), mouseX - (width / 2));
@@ -260,6 +264,31 @@ public class Spinner implements HitObject {
return false;
}
@Override
public float[] getPointAt(int trackPosition) {
// get spinner time
int timeDiff;
float x = hitObject.getScaledX(), y = hitObject.getScaledY();
if (trackPosition <= hitObject.getTime())
timeDiff = 0;
else if (trackPosition >= hitObject.getEndTime())
timeDiff = hitObject.getEndTime() - hitObject.getTime();
else
timeDiff = trackPosition - hitObject.getTime();
// calculate point
float multiplier = (GameMod.AUTO.isActive()) ? AUTO_MULTIPLIER : SPUN_OUT_MULTIPLIER;
float angle = (timeDiff * multiplier) - HALF_PI;
final float r = height / 10f;
return new float[] {
(float) (x + r * Math.cos(angle)),
(float) (y + r * Math.sin(angle))
};
}
@Override
public int getEndTime() { return hitObject.getEndTime(); }
/**
* Rotates the spinner by an angle.
* @param angle the angle to rotate (in radians)