Renamed GameScore class to GameData.
Makes more sense, since the class is responsible for more than just the score. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
ef9e38bf2d
commit
44bdf70c98
|
@ -34,9 +34,9 @@ import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds score data and renders all score-related elements.
|
* Holds game data and renders all related elements.
|
||||||
*/
|
*/
|
||||||
public class GameScore {
|
public class GameData {
|
||||||
/** Delta multiplier for steady HP drain. */
|
/** Delta multiplier for steady HP drain. */
|
||||||
public static final float HP_DRAIN_MULTIPLIER = 1 / 200f;
|
public static final float HP_DRAIN_MULTIPLIER = 1 / 200f;
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ public class GameScore {
|
||||||
* @param width container width
|
* @param width container width
|
||||||
* @param height container height
|
* @param height container height
|
||||||
*/
|
*/
|
||||||
public GameScore(int width, int height) {
|
public GameData(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
|
@ -20,7 +20,7 @@ package itdelatrisu.opsu.objects;
|
||||||
|
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.GameScore;
|
import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.OsuHitObject;
|
import itdelatrisu.opsu.OsuHitObject;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.audio.MusicController;
|
import itdelatrisu.opsu.audio.MusicController;
|
||||||
|
@ -40,8 +40,8 @@ public class Circle implements HitObject {
|
||||||
/** The associated Game object. */
|
/** The associated Game object. */
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
/** The associated GameScore object. */
|
/** The associated GameData object. */
|
||||||
private GameScore score;
|
private GameData data;
|
||||||
|
|
||||||
/** The color of this circle. */
|
/** The color of this circle. */
|
||||||
private Color color;
|
private Color color;
|
||||||
|
@ -66,14 +66,14 @@ public class Circle implements HitObject {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param hitObject the associated OsuHitObject
|
* @param hitObject the associated OsuHitObject
|
||||||
* @param game the associated Game object
|
* @param game the associated Game object
|
||||||
* @param score the associated GameScore object
|
* @param data the associated GameData object
|
||||||
* @param color the color of this circle
|
* @param color the color of this circle
|
||||||
* @param comboEnd true if this is the last hit object in the combo
|
* @param comboEnd true if this is the last hit object in the combo
|
||||||
*/
|
*/
|
||||||
public Circle(OsuHitObject hitObject, Game game, GameScore score, Color color, boolean comboEnd) {
|
public Circle(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
|
||||||
this.hitObject = hitObject;
|
this.hitObject = hitObject;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.score = score;
|
this.data = data;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.comboEnd = comboEnd;
|
this.comboEnd = comboEnd;
|
||||||
}
|
}
|
||||||
|
@ -94,15 +94,15 @@ public class Circle implements HitObject {
|
||||||
Utils.drawCentered(GameImage.HITCIRCLE.getImage(), x, y, color);
|
Utils.drawCentered(GameImage.HITCIRCLE.getImage(), x, y, color);
|
||||||
color.a = oldAlpha;
|
color.a = oldAlpha;
|
||||||
Utils.COLOR_WHITE_FADE.a = 1f;
|
Utils.COLOR_WHITE_FADE.a = 1f;
|
||||||
score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||||
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
|
GameImage.HITCIRCLE.getImage().getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the circle hit result.
|
* Calculates the circle hit result.
|
||||||
* @param time the hit object time (difference between track time)
|
* @param time the hit object time (difference between track time)
|
||||||
* @return the hit result (GameScore.HIT_* constants)
|
* @return the hit result (GameData.HIT_* constants)
|
||||||
*/
|
*/
|
||||||
private int hitResult(int time) {
|
private int hitResult(int time) {
|
||||||
int trackPosition = MusicController.getPosition();
|
int trackPosition = MusicController.getPosition();
|
||||||
|
@ -110,14 +110,14 @@ public class Circle implements HitObject {
|
||||||
|
|
||||||
int[] hitResultOffset = game.getHitResultOffsets();
|
int[] hitResultOffset = game.getHitResultOffsets();
|
||||||
int result = -1;
|
int result = -1;
|
||||||
if (timeDiff < hitResultOffset[GameScore.HIT_300])
|
if (timeDiff < hitResultOffset[GameData.HIT_300])
|
||||||
result = GameScore.HIT_300;
|
result = GameData.HIT_300;
|
||||||
else if (timeDiff < hitResultOffset[GameScore.HIT_100])
|
else if (timeDiff < hitResultOffset[GameData.HIT_100])
|
||||||
result = GameScore.HIT_100;
|
result = GameData.HIT_100;
|
||||||
else if (timeDiff < hitResultOffset[GameScore.HIT_50])
|
else if (timeDiff < hitResultOffset[GameData.HIT_50])
|
||||||
result = GameScore.HIT_50;
|
result = GameData.HIT_50;
|
||||||
else if (timeDiff < hitResultOffset[GameScore.HIT_MISS])
|
else if (timeDiff < hitResultOffset[GameData.HIT_MISS])
|
||||||
result = GameScore.HIT_MISS;
|
result = GameData.HIT_MISS;
|
||||||
//else not a hit
|
//else not a hit
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -130,7 +130,7 @@ public class Circle implements HitObject {
|
||||||
if (distance < circleRadius) {
|
if (distance < circleRadius) {
|
||||||
int result = hitResult(hitObject.getTime());
|
int result = hitResult(hitObject.getTime());
|
||||||
if (result > -1) {
|
if (result > -1) {
|
||||||
score.hitResult(
|
data.hitResult(
|
||||||
hitObject.getTime(), result,
|
hitObject.getTime(), result,
|
||||||
hitObject.getX(), hitObject.getY(),
|
hitObject.getX(), hitObject.getY(),
|
||||||
color, comboEnd, hitObject.getHitSoundType()
|
color, comboEnd, hitObject.getHitSoundType()
|
||||||
|
@ -151,19 +151,19 @@ public class Circle implements HitObject {
|
||||||
int[] hitResultOffset = game.getHitResultOffsets();
|
int[] hitResultOffset = game.getHitResultOffsets();
|
||||||
boolean isAutoMod = GameMod.AUTO.isActive();
|
boolean isAutoMod = GameMod.AUTO.isActive();
|
||||||
|
|
||||||
if (overlap || trackPosition > time + hitResultOffset[GameScore.HIT_50]) {
|
if (overlap || 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
|
||||||
score.hitResult(time, GameScore.HIT_300, x, y, color, comboEnd, hitSound);
|
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitSound);
|
||||||
|
|
||||||
else // no more points can be scored, so send a miss
|
else // no more points can be scored, so send a miss
|
||||||
score.hitResult(time, GameScore.HIT_MISS, x, y, null, comboEnd, hitSound);
|
data.hitResult(time, GameData.HIT_MISS, x, y, null, comboEnd, hitSound);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "auto" mod: send a perfect hit result
|
// "auto" mod: send a perfect hit result
|
||||||
else if (isAutoMod) {
|
else if (isAutoMod) {
|
||||||
if (Math.abs(trackPosition - time) < hitResultOffset[GameScore.HIT_300]) {
|
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
|
||||||
score.hitResult(time, GameScore.HIT_300, x, y, color, comboEnd, hitSound);
|
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitSound);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ package itdelatrisu.opsu.objects;
|
||||||
|
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.GameScore;
|
import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.OsuFile;
|
import itdelatrisu.opsu.OsuFile;
|
||||||
import itdelatrisu.opsu.OsuHitObject;
|
import itdelatrisu.opsu.OsuHitObject;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
|
@ -52,8 +52,8 @@ public class Slider implements HitObject {
|
||||||
/** The associated Game object. */
|
/** The associated Game object. */
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
/** The associated GameScore object. */
|
/** The associated GameData object. */
|
||||||
private GameScore score;
|
private GameData data;
|
||||||
|
|
||||||
/** The color of this slider. */
|
/** The color of this slider. */
|
||||||
private Color color;
|
private Color color;
|
||||||
|
@ -258,14 +258,14 @@ public class Slider implements HitObject {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param hitObject the associated OsuHitObject
|
* @param hitObject the associated OsuHitObject
|
||||||
* @param game the associated Game object
|
* @param game the associated Game object
|
||||||
* @param score the associated GameScore object
|
* @param data the associated GameData object
|
||||||
* @param color the color of this circle
|
* @param color the color of this circle
|
||||||
* @param comboEnd true if this is the last hit object in the combo
|
* @param comboEnd true if this is the last hit object in the combo
|
||||||
*/
|
*/
|
||||||
public Slider(OsuHitObject hitObject, Game game, GameScore score, Color color, boolean comboEnd) {
|
public Slider(OsuHitObject hitObject, Game game, GameData data, Color color, boolean comboEnd) {
|
||||||
this.hitObject = hitObject;
|
this.hitObject = hitObject;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.score = score;
|
this.data = data;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.comboEnd = comboEnd;
|
this.comboEnd = comboEnd;
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ public class Slider implements HitObject {
|
||||||
if (sliderClicked)
|
if (sliderClicked)
|
||||||
; // don't draw current combo number if already clicked
|
; // don't draw current combo number if already clicked
|
||||||
else
|
else
|
||||||
score.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
data.drawSymbolNumber(hitObject.getComboNumber(), x, y,
|
||||||
hitCircle.getWidth() * 0.40f / score.getDefaultSymbolImage(0).getHeight());
|
hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight());
|
||||||
|
|
||||||
color.a = oldAlpha;
|
color.a = oldAlpha;
|
||||||
Utils.COLOR_WHITE_FADE.a = oldAlphaFade;
|
Utils.COLOR_WHITE_FADE.a = oldAlphaFade;
|
||||||
|
@ -350,7 +350,7 @@ public class Slider implements HitObject {
|
||||||
* Calculates the slider hit result.
|
* Calculates the slider hit result.
|
||||||
* @param time the hit object time (difference between track time)
|
* @param time the hit object time (difference between track time)
|
||||||
* @param lastCircleHit true if the cursor was held within the last circle
|
* @param lastCircleHit true if the cursor was held within the last circle
|
||||||
* @return the hit result (GameScore.HIT_* constants)
|
* @return the hit result (GameData.HIT_* constants)
|
||||||
*/
|
*/
|
||||||
private int hitResult() {
|
private int hitResult() {
|
||||||
int lastIndex = hitObject.getSliderX().length - 1;
|
int lastIndex = hitObject.getSliderX().length - 1;
|
||||||
|
@ -358,20 +358,20 @@ public class Slider implements HitObject {
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
if (tickRatio >= 1.0f)
|
if (tickRatio >= 1.0f)
|
||||||
result = GameScore.HIT_300;
|
result = GameData.HIT_300;
|
||||||
else if (tickRatio >= 0.5f)
|
else if (tickRatio >= 0.5f)
|
||||||
result = GameScore.HIT_100;
|
result = GameData.HIT_100;
|
||||||
else if (tickRatio > 0f)
|
else if (tickRatio > 0f)
|
||||||
result = GameScore.HIT_50;
|
result = GameData.HIT_50;
|
||||||
else
|
else
|
||||||
result = GameScore.HIT_MISS;
|
result = GameData.HIT_MISS;
|
||||||
|
|
||||||
if (currentRepeats % 2 == 0) // last circle
|
if (currentRepeats % 2 == 0) // last circle
|
||||||
score.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
||||||
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex],
|
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex],
|
||||||
color, comboEnd, hitObject.getHitSoundType());
|
color, comboEnd, hitObject.getHitSoundType());
|
||||||
else // first circle
|
else // first circle
|
||||||
score.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
|
||||||
hitObject.getX(), hitObject.getY(), color, comboEnd, hitObject.getHitSoundType());
|
hitObject.getX(), hitObject.getY(), color, comboEnd, hitObject.getHitSoundType());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -390,16 +390,16 @@ public class Slider implements HitObject {
|
||||||
int[] hitResultOffset = game.getHitResultOffsets();
|
int[] hitResultOffset = game.getHitResultOffsets();
|
||||||
|
|
||||||
int result = -1;
|
int result = -1;
|
||||||
if (timeDiff < hitResultOffset[GameScore.HIT_50]) {
|
if (timeDiff < hitResultOffset[GameData.HIT_50]) {
|
||||||
result = GameScore.HIT_SLIDER30;
|
result = GameData.HIT_SLIDER30;
|
||||||
ticksHit++;
|
ticksHit++;
|
||||||
} else if (timeDiff < hitResultOffset[GameScore.HIT_MISS])
|
} else if (timeDiff < hitResultOffset[GameData.HIT_MISS])
|
||||||
result = GameScore.HIT_MISS;
|
result = GameData.HIT_MISS;
|
||||||
//else not a hit
|
//else not a hit
|
||||||
|
|
||||||
if (result > -1) {
|
if (result > -1) {
|
||||||
sliderClicked = true;
|
sliderClicked = true;
|
||||||
score.sliderTickResult(hitObject.getTime(), result,
|
data.sliderTickResult(hitObject.getTime(), result,
|
||||||
hitObject.getX(), hitObject.getY(), hitObject.getHitSoundType());
|
hitObject.getX(), hitObject.getY(), hitObject.getHitSoundType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -439,23 +439,23 @@ public class Slider implements HitObject {
|
||||||
int time = hitObject.getTime();
|
int time = hitObject.getTime();
|
||||||
|
|
||||||
// start circle time passed
|
// start circle time passed
|
||||||
if (trackPosition > time + hitResultOffset[GameScore.HIT_50]) {
|
if (trackPosition > time + hitResultOffset[GameData.HIT_50]) {
|
||||||
sliderClicked = true;
|
sliderClicked = true;
|
||||||
if (isAutoMod) { // "auto" mod: catch any missed notes due to lag
|
if (isAutoMod) { // "auto" mod: catch any missed notes due to lag
|
||||||
ticksHit++;
|
ticksHit++;
|
||||||
score.sliderTickResult(time, GameScore.HIT_SLIDER30,
|
data.sliderTickResult(time, GameData.HIT_SLIDER30,
|
||||||
hitObject.getX(), hitObject.getY(), hitSound);
|
hitObject.getX(), hitObject.getY(), hitSound);
|
||||||
} else
|
} else
|
||||||
score.sliderTickResult(time, GameScore.HIT_MISS,
|
data.sliderTickResult(time, GameData.HIT_MISS,
|
||||||
hitObject.getX(), hitObject.getY(), hitSound);
|
hitObject.getX(), hitObject.getY(), hitSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "auto" mod: send a perfect hit result
|
// "auto" mod: send a perfect hit result
|
||||||
else if (isAutoMod) {
|
else if (isAutoMod) {
|
||||||
if (Math.abs(trackPosition - time) < hitResultOffset[GameScore.HIT_300]) {
|
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
|
||||||
ticksHit++;
|
ticksHit++;
|
||||||
sliderClicked = true;
|
sliderClicked = true;
|
||||||
score.sliderTickResult(time, GameScore.HIT_SLIDER30,
|
data.sliderTickResult(time, GameData.HIT_SLIDER30,
|
||||||
hitObject.getX(), hitObject.getY(), hitSound);
|
hitObject.getX(), hitObject.getY(), hitSound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,32 +514,32 @@ public class Slider implements HitObject {
|
||||||
if ((Utils.isGameKeyPressed() && distance < followCircleRadius) || isAutoMod) {
|
if ((Utils.isGameKeyPressed() && distance < followCircleRadius) || isAutoMod) {
|
||||||
// mouse pressed and within follow circle
|
// mouse pressed and within follow circle
|
||||||
followCircleActive = true;
|
followCircleActive = true;
|
||||||
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
|
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
|
||||||
|
|
||||||
// held during new repeat
|
// held during new repeat
|
||||||
if (isNewRepeat) {
|
if (isNewRepeat) {
|
||||||
ticksHit++;
|
ticksHit++;
|
||||||
if (currentRepeats % 2 > 0) // last circle
|
if (currentRepeats % 2 > 0) // last circle
|
||||||
score.sliderTickResult(trackPosition, GameScore.HIT_SLIDER30,
|
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
|
||||||
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex], hitSound);
|
hitObject.getSliderX()[lastIndex], hitObject.getSliderY()[lastIndex], hitSound);
|
||||||
else // first circle
|
else // first circle
|
||||||
score.sliderTickResult(trackPosition, GameScore.HIT_SLIDER30,
|
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER30,
|
||||||
c[0], c[1], hitSound);
|
c[0], c[1], hitSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// held during new tick
|
// held during new tick
|
||||||
if (isNewTick) {
|
if (isNewTick) {
|
||||||
ticksHit++;
|
ticksHit++;
|
||||||
score.sliderTickResult(trackPosition, GameScore.HIT_SLIDER10,
|
data.sliderTickResult(trackPosition, GameData.HIT_SLIDER10,
|
||||||
c[0], c[1], (byte) -1);
|
c[0], c[1], (byte) -1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
followCircleActive = false;
|
followCircleActive = false;
|
||||||
|
|
||||||
if (isNewRepeat)
|
if (isNewRepeat)
|
||||||
score.sliderTickResult(trackPosition, GameScore.HIT_MISS, 0, 0, (byte) -1);
|
data.sliderTickResult(trackPosition, GameData.HIT_MISS, 0, 0, (byte) -1);
|
||||||
if (isNewTick)
|
if (isNewTick)
|
||||||
score.sliderTickResult(trackPosition, GameScore.HIT_MISS, 0, 0, (byte) -1);
|
data.sliderTickResult(trackPosition, GameData.HIT_MISS, 0, 0, (byte) -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -20,7 +20,7 @@ package itdelatrisu.opsu.objects;
|
||||||
|
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.GameScore;
|
import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.OsuHitObject;
|
import itdelatrisu.opsu.OsuHitObject;
|
||||||
import itdelatrisu.opsu.Utils;
|
import itdelatrisu.opsu.Utils;
|
||||||
import itdelatrisu.opsu.audio.MusicController;
|
import itdelatrisu.opsu.audio.MusicController;
|
||||||
|
@ -43,8 +43,8 @@ public class Spinner implements HitObject {
|
||||||
/** The associated OsuHitObject. */
|
/** The associated OsuHitObject. */
|
||||||
private OsuHitObject hitObject;
|
private OsuHitObject hitObject;
|
||||||
|
|
||||||
/** The associated GameScore object. */
|
/** The associated GameData object. */
|
||||||
private GameScore score;
|
private GameData data;
|
||||||
|
|
||||||
/** The last rotation angle. */
|
/** The last rotation angle. */
|
||||||
private float lastAngle = -1f;
|
private float lastAngle = -1f;
|
||||||
|
@ -68,14 +68,14 @@ public class Spinner implements HitObject {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param hitObject the associated OsuHitObject
|
* @param hitObject the associated OsuHitObject
|
||||||
* @param game the associated Game object
|
* @param game the associated Game object
|
||||||
* @param score the associated GameScore object
|
* @param data the associated GameData object
|
||||||
*/
|
*/
|
||||||
public Spinner(OsuHitObject hitObject, Game game, GameScore score) {
|
public Spinner(OsuHitObject hitObject, Game game, GameData data) {
|
||||||
this.hitObject = hitObject;
|
this.hitObject = hitObject;
|
||||||
this.score = score;
|
this.data = data;
|
||||||
|
|
||||||
// calculate rotations needed
|
// calculate rotations needed
|
||||||
float spinsPerMinute = 100 + (score.getDifficulty() * 15);
|
float spinsPerMinute = 100 + (data.getDifficulty() * 15);
|
||||||
rotationsNeeded = spinsPerMinute * (hitObject.getEndTime() - hitObject.getTime()) / 60000f;
|
rotationsNeeded = spinsPerMinute * (hitObject.getEndTime() - hitObject.getTime()) / 60000f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,13 +117,13 @@ public class Spinner implements HitObject {
|
||||||
GameImage.SPINNER_CLEAR.getImage().drawCentered(width / 2, height / 4);
|
GameImage.SPINNER_CLEAR.getImage().drawCentered(width / 2, height / 4);
|
||||||
int extraRotations = (int) (rotations - rotationsNeeded);
|
int extraRotations = (int) (rotations - rotationsNeeded);
|
||||||
if (extraRotations > 0)
|
if (extraRotations > 0)
|
||||||
score.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
|
data.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates and sends the spinner hit result.
|
* Calculates and sends the spinner hit result.
|
||||||
* @return the hit result (GameScore.HIT_* constants)
|
* @return the hit result (GameData.HIT_* constants)
|
||||||
*/
|
*/
|
||||||
private int hitResult() {
|
private int hitResult() {
|
||||||
// TODO: verify ratios
|
// TODO: verify ratios
|
||||||
|
@ -132,16 +132,16 @@ public class Spinner implements HitObject {
|
||||||
float ratio = rotations / rotationsNeeded;
|
float ratio = rotations / rotationsNeeded;
|
||||||
if (ratio >= 1.0f ||
|
if (ratio >= 1.0f ||
|
||||||
GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) {
|
GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) {
|
||||||
result = GameScore.HIT_300;
|
result = GameData.HIT_300;
|
||||||
SoundController.playSound(SoundEffect.SPINNEROSU);
|
SoundController.playSound(SoundEffect.SPINNEROSU);
|
||||||
} else if (ratio >= 0.8f)
|
} else if (ratio >= 0.8f)
|
||||||
result = GameScore.HIT_100;
|
result = GameData.HIT_100;
|
||||||
else if (ratio >= 0.5f)
|
else if (ratio >= 0.5f)
|
||||||
result = GameScore.HIT_50;
|
result = GameData.HIT_50;
|
||||||
else
|
else
|
||||||
result = GameScore.HIT_MISS;
|
result = GameData.HIT_MISS;
|
||||||
|
|
||||||
score.hitResult(hitObject.getEndTime(), result, width / 2, height / 2,
|
data.hitResult(hitObject.getEndTime(), result, width / 2, height / 2,
|
||||||
Color.transparent, true, (byte) -1);
|
Color.transparent, true, (byte) -1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -164,12 +164,12 @@ public class Spinner implements HitObject {
|
||||||
// spin automatically (TODO: correct rotation angles)
|
// spin automatically (TODO: correct rotation angles)
|
||||||
if (GameMod.AUTO.isActive()) {
|
if (GameMod.AUTO.isActive()) {
|
||||||
// "auto" mod (fast)
|
// "auto" mod (fast)
|
||||||
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
|
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
|
||||||
rotate(delta / 20f);
|
rotate(delta / 20f);
|
||||||
return false;
|
return false;
|
||||||
} else if (GameMod.SPUN_OUT.isActive()) {
|
} else if (GameMod.SPUN_OUT.isActive()) {
|
||||||
// "spun out" mod (slow)
|
// "spun out" mod (slow)
|
||||||
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
|
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
|
||||||
rotate(delta / 32f);
|
rotate(delta / 32f);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ public class Spinner implements HitObject {
|
||||||
if (lastAngle >= 0f) { // skip initial clicks
|
if (lastAngle >= 0f) { // skip initial clicks
|
||||||
float angleDiff = Math.abs(lastAngle - angle);
|
float angleDiff = Math.abs(lastAngle - angle);
|
||||||
if (angleDiff < Math.PI / 2) { // skip huge angle changes...
|
if (angleDiff < Math.PI / 2) { // skip huge angle changes...
|
||||||
score.changeHealth(delta * GameScore.HP_DRAIN_MULTIPLIER);
|
data.changeHealth(delta * GameData.HP_DRAIN_MULTIPLIER);
|
||||||
rotate(angleDiff);
|
rotate(angleDiff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,10 +207,10 @@ public class Spinner implements HitObject {
|
||||||
// added one whole rotation...
|
// added one whole rotation...
|
||||||
if (Math.floor(newRotations) > rotations) {
|
if (Math.floor(newRotations) > rotations) {
|
||||||
if (newRotations > rotationsNeeded) { // extra rotations
|
if (newRotations > rotationsNeeded) { // extra rotations
|
||||||
score.changeScore(1000);
|
data.changeScore(1000);
|
||||||
SoundController.playSound(SoundEffect.SPINNERBONUS);
|
SoundController.playSound(SoundEffect.SPINNERBONUS);
|
||||||
} else {
|
} else {
|
||||||
score.changeScore(100);
|
data.changeScore(100);
|
||||||
SoundController.playSound(SoundEffect.SPINNERSPIN);
|
SoundController.playSound(SoundEffect.SPINNERSPIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ package itdelatrisu.opsu.states;
|
||||||
import itdelatrisu.opsu.ErrorHandler;
|
import itdelatrisu.opsu.ErrorHandler;
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.GameScore;
|
import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.MenuButton;
|
import itdelatrisu.opsu.MenuButton;
|
||||||
import itdelatrisu.opsu.Opsu;
|
import itdelatrisu.opsu.Opsu;
|
||||||
import itdelatrisu.opsu.Options;
|
import itdelatrisu.opsu.Options;
|
||||||
|
@ -73,8 +73,8 @@ public class Game extends BasicGameState {
|
||||||
/** The associated OsuFile object. */
|
/** The associated OsuFile object. */
|
||||||
private OsuFile osu;
|
private OsuFile osu;
|
||||||
|
|
||||||
/** The associated GameScore object (holds all score data). */
|
/** The associated GameData object. */
|
||||||
private GameScore score;
|
private GameData data;
|
||||||
|
|
||||||
/** Current hit object index in OsuHitObject[] array. */
|
/** Current hit object index in OsuHitObject[] array. */
|
||||||
private int objectIndex = 0;
|
private int objectIndex = 0;
|
||||||
|
@ -158,9 +158,9 @@ public class Game extends BasicGameState {
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int height = container.getHeight();
|
int height = container.getHeight();
|
||||||
|
|
||||||
// create the associated GameScore object
|
// create the associated GameData object
|
||||||
score = new GameScore(width, height);
|
data = new GameData(width, height);
|
||||||
((GameRanking) game.getState(Opsu.STATE_GAMERANKING)).setGameScore(score);
|
((GameRanking) game.getState(Opsu.STATE_GAMERANKING)).setGameData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -215,13 +215,13 @@ public class Game extends BasicGameState {
|
||||||
g.fillRect(0, height * 0.875f, width, height * 0.125f);
|
g.fillRect(0, height * 0.875f, width, height * 0.125f);
|
||||||
}
|
}
|
||||||
|
|
||||||
score.drawGameElements(g, true, objectIndex == 0);
|
data.drawGameElements(g, true, objectIndex == 0);
|
||||||
|
|
||||||
if (breakLength >= 8000 &&
|
if (breakLength >= 8000 &&
|
||||||
trackPosition - breakTime > 2000 &&
|
trackPosition - breakTime > 2000 &&
|
||||||
trackPosition - breakTime < 5000) {
|
trackPosition - breakTime < 5000) {
|
||||||
// show break start
|
// show break start
|
||||||
if (score.getHealth() >= 50) {
|
if (data.getHealth() >= 50) {
|
||||||
GameImage.SECTION_PASS.getImage().drawCentered(width / 2f, height / 2f);
|
GameImage.SECTION_PASS.getImage().drawCentered(width / 2f, height / 2f);
|
||||||
if (!breakSound) {
|
if (!breakSound) {
|
||||||
SoundController.playSound(SoundEffect.SECTIONPASS);
|
SoundController.playSound(SoundEffect.SECTIONPASS);
|
||||||
|
@ -258,7 +258,7 @@ public class Game extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// game elements
|
// game elements
|
||||||
score.drawGameElements(g, false, objectIndex == 0);
|
data.drawGameElements(g, false, objectIndex == 0);
|
||||||
|
|
||||||
// skip beginning
|
// skip beginning
|
||||||
if (objectIndex == 0 &&
|
if (objectIndex == 0 &&
|
||||||
|
@ -338,7 +338,7 @@ public class Game extends BasicGameState {
|
||||||
hitObjects[stack.pop()].draw(trackPosition, stack.isEmpty(), g);
|
hitObjects[stack.pop()].draw(trackPosition, stack.isEmpty(), g);
|
||||||
|
|
||||||
// draw OsuHitObjectResult objects
|
// draw OsuHitObjectResult objects
|
||||||
score.drawHitResults(trackPosition);
|
data.drawHitResults(trackPosition);
|
||||||
|
|
||||||
if (GameMod.AUTO.isActive())
|
if (GameMod.AUTO.isActive())
|
||||||
GameImage.UNRANKED.getImage().drawCentered(width / 2, height * 0.077f);
|
GameImage.UNRANKED.getImage().drawCentered(width / 2, height * 0.077f);
|
||||||
|
@ -405,15 +405,15 @@ public class Game extends BasicGameState {
|
||||||
|
|
||||||
// "Easy" mod: multiple "lives"
|
// "Easy" mod: multiple "lives"
|
||||||
if (GameMod.EASY.isActive() && deathTime > -1) {
|
if (GameMod.EASY.isActive() && deathTime > -1) {
|
||||||
if (score.getHealth() < 99f)
|
if (data.getHealth() < 99f)
|
||||||
score.changeHealth(delta / 10f);
|
data.changeHealth(delta / 10f);
|
||||||
else {
|
else {
|
||||||
MusicController.resume();
|
MusicController.resume();
|
||||||
deathTime = -1;
|
deathTime = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
score.updateDisplays(delta);
|
data.updateDisplays(delta);
|
||||||
|
|
||||||
// map complete!
|
// map complete!
|
||||||
if (objectIndex >= osu.objects.length) {
|
if (objectIndex >= osu.objects.length) {
|
||||||
|
@ -477,8 +477,8 @@ public class Game extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// drain health
|
// drain health
|
||||||
score.changeHealth(delta * -1 * GameScore.HP_DRAIN_MULTIPLIER);
|
data.changeHealth(delta * -1 * GameData.HP_DRAIN_MULTIPLIER);
|
||||||
if (!score.isAlive()) {
|
if (!data.isAlive()) {
|
||||||
// "Easy" mod
|
// "Easy" mod
|
||||||
if (GameMod.EASY.isActive()) {
|
if (GameMod.EASY.isActive()) {
|
||||||
deaths++;
|
deaths++;
|
||||||
|
@ -498,7 +498,7 @@ public class Game extends BasicGameState {
|
||||||
while (objectIndex < osu.objects.length && trackPosition > osu.objects[objectIndex].getTime()) {
|
while (objectIndex < osu.objects.length && trackPosition > osu.objects[objectIndex].getTime()) {
|
||||||
// check if we've already passed the next object's start time
|
// check if we've already passed the next object's start time
|
||||||
boolean overlap = (objectIndex + 1 < osu.objects.length &&
|
boolean overlap = (objectIndex + 1 < osu.objects.length &&
|
||||||
trackPosition > osu.objects[objectIndex + 1].getTime() - hitResultOffset[GameScore.HIT_300]);
|
trackPosition > osu.objects[objectIndex + 1].getTime() - hitResultOffset[GameData.HIT_300]);
|
||||||
|
|
||||||
// update hit object and check completion status
|
// update hit object and check completion status
|
||||||
if (hitObjects[objectIndex].update(overlap, delta, mouseX, mouseY))
|
if (hitObjects[objectIndex].update(overlap, delta, mouseX, mouseY))
|
||||||
|
@ -698,11 +698,11 @@ public class Game extends BasicGameState {
|
||||||
|
|
||||||
Color color = osu.combo[hitObject.getComboIndex()];
|
Color color = osu.combo[hitObject.getComboIndex()];
|
||||||
if (hitObject.isCircle())
|
if (hitObject.isCircle())
|
||||||
hitObjects[i] = new Circle(hitObject, this, score, color, comboEnd);
|
hitObjects[i] = new Circle(hitObject, this, data, color, comboEnd);
|
||||||
else if (hitObject.isSlider())
|
else if (hitObject.isSlider())
|
||||||
hitObjects[i] = new Slider(hitObject, this, score, color, comboEnd);
|
hitObjects[i] = new Slider(hitObject, this, data, color, comboEnd);
|
||||||
else if (hitObject.isSpinner())
|
else if (hitObject.isSpinner())
|
||||||
hitObjects[i] = new Spinner(hitObject, this, score);
|
hitObjects[i] = new Spinner(hitObject, this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the first timingPoint
|
// load the first timingPoint
|
||||||
|
@ -734,7 +734,7 @@ public class Game extends BasicGameState {
|
||||||
*/
|
*/
|
||||||
public void resetGameData() {
|
public void resetGameData() {
|
||||||
hitObjects = new HitObject[osu.objects.length];
|
hitObjects = new HitObject[osu.objects.length];
|
||||||
score.clear();
|
data.clear();
|
||||||
objectIndex = 0;
|
objectIndex = 0;
|
||||||
breakIndex = 0;
|
breakIndex = 0;
|
||||||
breakTime = 0;
|
breakTime = 0;
|
||||||
|
@ -800,7 +800,7 @@ public class Game extends BasicGameState {
|
||||||
|
|
||||||
// load other images...
|
// load other images...
|
||||||
((GamePauseMenu) game.getState(Opsu.STATE_GAMEPAUSEMENU)).loadImages();
|
((GamePauseMenu) game.getState(Opsu.STATE_GAMEPAUSEMENU)).loadImages();
|
||||||
score.loadImages(osu.getFile().getParentFile());
|
data.loadImages(osu.getFile().getParentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -851,15 +851,15 @@ public class Game extends BasicGameState {
|
||||||
approachTime = (int) (1200 - ((approachRate - 5) * 150));
|
approachTime = (int) (1200 - ((approachRate - 5) * 150));
|
||||||
|
|
||||||
// overallDifficulty (hit result time offsets)
|
// overallDifficulty (hit result time offsets)
|
||||||
hitResultOffset = new int[GameScore.HIT_MAX];
|
hitResultOffset = new int[GameData.HIT_MAX];
|
||||||
hitResultOffset[GameScore.HIT_300] = (int) (78 - (overallDifficulty * 6));
|
hitResultOffset[GameData.HIT_300] = (int) (78 - (overallDifficulty * 6));
|
||||||
hitResultOffset[GameScore.HIT_100] = (int) (138 - (overallDifficulty * 8));
|
hitResultOffset[GameData.HIT_100] = (int) (138 - (overallDifficulty * 8));
|
||||||
hitResultOffset[GameScore.HIT_50] = (int) (198 - (overallDifficulty * 10));
|
hitResultOffset[GameData.HIT_50] = (int) (198 - (overallDifficulty * 10));
|
||||||
hitResultOffset[GameScore.HIT_MISS] = (int) (500 - (overallDifficulty * 10));
|
hitResultOffset[GameData.HIT_MISS] = (int) (500 - (overallDifficulty * 10));
|
||||||
|
|
||||||
// HPDrainRate (health change), overallDifficulty (scoring)
|
// HPDrainRate (health change), overallDifficulty (scoring)
|
||||||
score.setDrainRate(HPDrainRate);
|
data.setDrainRate(HPDrainRate);
|
||||||
score.setDifficulty(overallDifficulty);
|
data.setDifficulty(overallDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -879,7 +879,7 @@ public class Game extends BasicGameState {
|
||||||
public int getApproachTime() { return approachTime; }
|
public int getApproachTime() { return approachTime; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of hit result offset times, in milliseconds (indexed by GameScore.HIT_* constants).
|
* Returns an array of hit result offset times, in milliseconds (indexed by GameData.HIT_* constants).
|
||||||
*/
|
*/
|
||||||
public int[] getHitResultOffsets() { return hitResultOffset; }
|
public int[] getHitResultOffsets() { return hitResultOffset; }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package itdelatrisu.opsu.states;
|
||||||
|
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.GameMod;
|
import itdelatrisu.opsu.GameMod;
|
||||||
import itdelatrisu.opsu.GameScore;
|
import itdelatrisu.opsu.GameData;
|
||||||
import itdelatrisu.opsu.MenuButton;
|
import itdelatrisu.opsu.MenuButton;
|
||||||
import itdelatrisu.opsu.Opsu;
|
import itdelatrisu.opsu.Opsu;
|
||||||
import itdelatrisu.opsu.OsuFile;
|
import itdelatrisu.opsu.OsuFile;
|
||||||
|
@ -50,8 +50,8 @@ import org.newdawn.slick.state.transition.FadeOutTransition;
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public class GameRanking extends BasicGameState {
|
public class GameRanking extends BasicGameState {
|
||||||
/** Associated GameScore object. */
|
/** Associated GameData object. */
|
||||||
private GameScore score;
|
private GameData data;
|
||||||
|
|
||||||
/** "Retry" and "Exit" buttons. */
|
/** "Retry" and "Exit" buttons. */
|
||||||
private MenuButton retryButton, exitButton;
|
private MenuButton retryButton, exitButton;
|
||||||
|
@ -100,7 +100,7 @@ public class GameRanking extends BasicGameState {
|
||||||
g.setBackground(Utils.COLOR_BLACK_ALPHA);
|
g.setBackground(Utils.COLOR_BLACK_ALPHA);
|
||||||
|
|
||||||
// ranking screen elements
|
// ranking screen elements
|
||||||
score.drawRankingElements(g, width, height);
|
data.drawRankingElements(g, width, height);
|
||||||
|
|
||||||
// game mods
|
// game mods
|
||||||
for (GameMod mod : GameMod.VALUES_REVERSED) {
|
for (GameMod mod : GameMod.VALUES_REVERSED) {
|
||||||
|
@ -196,10 +196,10 @@ public class GameRanking extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the associated GameScore object.
|
* Sets the associated GameData object.
|
||||||
* @param score the GameScore
|
* @param data the GameData
|
||||||
*/
|
*/
|
||||||
public void setGameScore(GameScore score) {
|
public void setGameData(GameData data) {
|
||||||
this.score = score;
|
this.data = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user