Added retry counter.

Display number of retries (after retrying at least twice).

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2014-12-29 23:35:31 -05:00
parent cc84d4a3e4
commit 9e69afac91
2 changed files with 56 additions and 27 deletions

View File

@ -193,6 +193,11 @@ public class Game extends BasicGameState {
*/ */
private int deathTime = -1; private int deathTime = -1;
/**
* Number of retries.
*/
private int retries = 0;
// game-related variables // game-related variables
private GameContainer container; private GameContainer container;
private StateBasedGame game; private StateBasedGame game;
@ -246,6 +251,8 @@ public class Game extends BasicGameState {
trackPosition = pauseTime; trackPosition = pauseTime;
else if (deathTime > -1) // "Easy" mod: health bar increasing else if (deathTime > -1) // "Easy" mod: health bar increasing
trackPosition = deathTime; trackPosition = deathTime;
int firstObjectTime = osu.objects[0].getTime();
int timeDiff = firstObjectTime - trackPosition;
// checkpoint // checkpoint
if (checkpointLoaded) { if (checkpointLoaded) {
@ -257,8 +264,8 @@ public class Game extends BasicGameState {
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(checkpoint)) TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(checkpoint))
); );
Utils.FONT_MEDIUM.drawString( Utils.FONT_MEDIUM.drawString(
(container.getWidth() - Utils.FONT_MEDIUM.getWidth(checkpointText)) / 2, (width - Utils.FONT_MEDIUM.getWidth(checkpointText)) / 2,
container.getHeight() - 15 - Utils.FONT_MEDIUM.getLineHeight(), height - 15 - Utils.FONT_MEDIUM.getLineHeight(),
checkpointText, Color.white checkpointText, Color.white
); );
} }
@ -323,16 +330,31 @@ public class Game extends BasicGameState {
// skip beginning // skip beginning
if (objectIndex == 0 && if (objectIndex == 0 &&
osu.objects[0].getTime() - SKIP_OFFSET > 5000 && firstObjectTime - SKIP_OFFSET > 5000 &&
trackPosition < osu.objects[0].getTime() - SKIP_OFFSET) trackPosition < osu.objects[0].getTime() - SKIP_OFFSET)
skipButton.draw(); skipButton.draw();
// show retries
if (retries >= 2 && timeDiff >= -1000) {
int retryHeight = Math.max(
GameImage.SCOREBAR_BG.getImage().getHeight(),
GameImage.SCOREBAR_KI.getImage().getHeight()
);
if (timeDiff < -500)
Utils.COLOR_WHITE_FADE.a = (1000 + timeDiff) / 500f;
Utils.FONT_MEDIUM.drawString(
2 + (width / 100), retryHeight,
String.format("%d retries and counting...", retries),
Utils.COLOR_WHITE_FADE
);
Utils.COLOR_WHITE_FADE.a = 1f;
}
if (isLeadIn()) if (isLeadIn())
trackPosition = leadInTime * -1; // render approach circles during song lead-in trackPosition = leadInTime * -1; // render approach circles during song lead-in
// countdown // countdown
if (osu.countdown > 0) { // TODO: implement half/double rate settings if (osu.countdown > 0) { // TODO: implement half/double rate settings
int timeDiff = osu.objects[0].getTime() - trackPosition;
if (timeDiff >= 500 && timeDiff < 3000) { if (timeDiff >= 500 && timeDiff < 3000) {
if (timeDiff >= 1500) { if (timeDiff >= 1500) {
GameImage.COUNTDOWN_READY.getImage().drawCentered(width / 2, height / 2); GameImage.COUNTDOWN_READY.getImage().drawCentered(width / 2, height / 2);
@ -582,6 +604,8 @@ public class Game extends BasicGameState {
@Override @Override
public void keyPressed(int key, char c) { public void keyPressed(int key, char c) {
int trackPosition = MusicController.getPosition();
// game keys // game keys
if (!Keyboard.isRepeatEvent()) { if (!Keyboard.isRepeatEvent()) {
if (key == Options.getGameKeyLeft()) if (key == Options.getGameKeyLeft())
@ -593,7 +617,6 @@ public class Game extends BasicGameState {
switch (key) { switch (key) {
case Input.KEY_ESCAPE: case Input.KEY_ESCAPE:
// pause game // pause game
int trackPosition = MusicController.getPosition();
if (pauseTime < 0 && breakTime <= 0 && if (pauseTime < 0 && breakTime <= 0 &&
trackPosition >= osu.objects[0].getTime() && trackPosition >= osu.objects[0].getTime() &&
!GameMod.AUTO.isActive()) { !GameMod.AUTO.isActive()) {
@ -613,6 +636,8 @@ public class Game extends BasicGameState {
// restart // restart
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) { if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
try { try {
if (trackPosition < osu.objects[0].getTime())
retries--; // don't count this retry (cancel out later increment)
restart = RESTART_MANUAL; restart = RESTART_MANUAL;
enter(container, game); enter(container, game);
skipIntro(); skipIntro();
@ -627,7 +652,7 @@ public class Game extends BasicGameState {
if (isLeadIn()) if (isLeadIn())
break; break;
int position = (pauseTime > -1) ? pauseTime : MusicController.getPosition(); int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000)) if (Options.setCheckpoint(position / 1000))
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundController.SOUND_MENUCLICK);
} }
@ -651,7 +676,7 @@ public class Game extends BasicGameState {
// skip to checkpoint // skip to checkpoint
MusicController.setPosition(checkpoint); MusicController.setPosition(checkpoint);
while (objectIndex < osu.objects.length && while (objectIndex < osu.objects.length &&
osu.objects[objectIndex++].getTime() <= MusicController.getPosition()) osu.objects[objectIndex++].getTime() <= trackPosition)
; ;
objectIndex--; objectIndex--;
} catch (SlickException e) { } catch (SlickException e) {
@ -730,7 +755,9 @@ public class Game extends BasicGameState {
if (restart == RESTART_NEW) { if (restart == RESTART_NEW) {
loadImages(); loadImages();
setMapModifiers(); setMapModifiers();
} retries = 0;
} else
retries++;
// initialize object maps // initialize object maps
circles = new HashMap<Integer, Circle>(); circles = new HashMap<Integer, Circle>();

View File

@ -128,8 +128,18 @@ public class GamePauseMenu extends BasicGameState {
MusicController.playAt(MusicController.getOsuFile().previewTime, true); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundController.SOUND_MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else } else {
unPause(Game.RESTART_FALSE); SoundController.playSound(SoundController.SOUND_MENUBACK);
Game.setRestart(Game.RESTART_FALSE);
game.enterState(Opsu.STATE_GAME);
}
break;
case Input.KEY_R:
// restart
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
Game.setRestart(Game.RESTART_MANUAL);
game.enterState(Opsu.STATE_GAME);
}
break; break;
case Input.KEY_F12: case Input.KEY_F12:
Utils.takeScreenShot(); Utils.takeScreenShot();
@ -148,10 +158,14 @@ public class GamePauseMenu extends BasicGameState {
if (loseState && System.currentTimeMillis() - pauseStartTime < FADEOUT_TIME) if (loseState && System.currentTimeMillis() - pauseStartTime < FADEOUT_TIME)
return; return;
if (continueButton.contains(x, y) && !loseState) if (continueButton.contains(x, y) && !loseState) {
unPause(Game.RESTART_FALSE); SoundController.playSound(SoundController.SOUND_MENUBACK);
else if (retryButton.contains(x, y)) { Game.setRestart(Game.RESTART_FALSE);
unPause(Game.RESTART_MANUAL); game.enterState(Opsu.STATE_GAME);
} else if (retryButton.contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUHIT);
Game.setRestart(Game.RESTART_MANUAL);
game.enterState(Opsu.STATE_GAME);
} else if (backButton.contains(x, y)) { } else if (backButton.contains(x, y)) {
MusicController.pause(); // lose state MusicController.pause(); // lose state
MusicController.playAt(MusicController.getOsuFile().previewTime, true); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
@ -174,18 +188,6 @@ public class GamePauseMenu extends BasicGameState {
backButton.setScale(1f); backButton.setScale(1f);
} }
/**
* Unpause and return to the Game state.
*/
private void unPause(byte restart) {
if (restart == Game.RESTART_MANUAL)
SoundController.playSound(SoundController.SOUND_MENUHIT);
else
SoundController.playSound(SoundController.SOUND_MENUBACK);
Game.setRestart(restart);
game.enterState(Opsu.STATE_GAME);
}
/** /**
* Loads all game pause/fail menu images. * Loads all game pause/fail menu images.
*/ */