diff --git a/audio/SongInstance.java b/audio/SongInstance.java index 858a3e2..c4e7a76 100644 --- a/audio/SongInstance.java +++ b/audio/SongInstance.java @@ -61,6 +61,11 @@ public class SongInstance { return b; } + public long getEndTime() + { + return objects.get(objects.size()-1).getTime(); + } + public List getButtonsBetween(long oldProgress, long progress) { List b = new ArrayList(); diff --git a/model/GameModel.java b/model/GameModel.java index 5c55122..9e593ad 100644 --- a/model/GameModel.java +++ b/model/GameModel.java @@ -9,7 +9,7 @@ import control.button.ButtonHandler; public class GameModel { - public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.WHITE }; + public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.ORANGE }; private GameStateManager gsm; private LedHandler led; private int count = 0; diff --git a/model/gameState/MenuState.java b/model/gameState/MenuState.java index c6761d9..ab13fb4 100644 --- a/model/gameState/MenuState.java +++ b/model/gameState/MenuState.java @@ -25,6 +25,7 @@ import audio.SongInstance; import audio.sorting.SortALPHA; import audio.sorting.SortPLAYED; import control.GameStateManager; +import control.GameStateManager.State; import control.button.ButtonEvent; import control.button.ButtonHandler; import control.joystick.Joystick; @@ -150,6 +151,11 @@ public class MenuState extends GameState { selected = 0; } } + + if(e.getButton().getButtonID() == 0) + { + gsm.setState(State.TITLE_STATE); + } } @Override public void buttonReleased(ButtonEvent e) { diff --git a/model/gameState/PlayState.java b/model/gameState/PlayState.java index 56a9fa6..db5f309 100644 --- a/model/gameState/PlayState.java +++ b/model/gameState/PlayState.java @@ -39,7 +39,7 @@ public class PlayState extends GameState { public PlayState(GameStateManager gsm, SongHandler sh) { super(gsm, sh); - infoPanel = new InfoPanel(0, 0); + infoPanel = new InfoPanel(0, 0, sh); area = new PlayArea(256, 1024, 1024, 125); player = new Player(1280 - 1024 + 1024 / 2, 1024 / 2); stroke = new BasicStroke(sizeOfEnemy, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); @@ -89,6 +89,9 @@ public class PlayState extends GameState { Path p = area.paths.get(ob.getDirection()); p.addEnemy(ob.getColor(), ob.getDirection(), (int) ob.getLength()); } + + if(progress > sh.getCurrentSongInstance().getEndTime() + Enemy.secondsToEnd*1000*2) + gsm.setState(State.GAMEOVER_STATE); oldProgress = progress; diff --git a/model/objects/InfoPanel.java b/model/objects/InfoPanel.java index 8fd32c0..624d040 100644 --- a/model/objects/InfoPanel.java +++ b/model/objects/InfoPanel.java @@ -9,6 +9,7 @@ import java.awt.RenderingHints; import java.awt.Transparency; import java.awt.image.VolatileImage; +import model.SongHandler; import model.gameState.PlayState; public class InfoPanel { @@ -16,17 +17,32 @@ public class InfoPanel { private static String totalHighscore = "000000"; private int x, y; private VolatileImage infoPanel; + private SongHandler sh; + private String time; - public InfoPanel(int x, int y){ + public InfoPanel(int x, int y, SongHandler sh){ this.x = x; this.y = y; + this.sh = sh; updateIPanel(); generateInfoPanel(); } public void updateIPanel() { totalHighscore = "" + PlayState.currentScore; +// time = ""; +// long progress = (sh.getProgress() / 1000); +// time = progress%1000 + time; +// progress /= 1000; +// time = progress%1000 + ":" + time; +// progress /= 1000; +// time = progress + ":" + time; + long progress = (sh.getProgress() / 1000); + String millis = ((progress) % 1000) + "".length() >= 3 ? ("" +((progress) % 1000)).substring(0, 2) : "" + ((progress) % 1000); + String second = ((progress / 1000) % 60 + "").length() <= 1 ? "0" +((progress / 1000) % 60) : "" + ((progress / 1000) % 60); + String minute = ((progress / (1000 * 60)) % 60 + "").length() <= 1 ? "0" +((progress / (1000 * 60)) % 60) : "" + ((progress / (1000 * 60)) % 60); + time = minute + ":" + second + ":" + millis; generateInfoPanel(); } @@ -41,13 +57,26 @@ public class InfoPanel { Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30); g2.setFont(scoreFont); - g2.setColor(Color.ORANGE); + g2.setColor(Color.GREEN); + g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30); + g2.setColor(Color.ORANGE); g2.drawString("Score: " + totalHighscore, 25, 75); g2.drawRect(25, 100, 200, 30); g2.drawRect(25, 300, 200, 700); - g2.setColor(Color.GREEN); - g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30); + + g2.drawString(sh.getCurrentSong().getTitle(), 25, 200); + if(sh.getCurrentSong().getSubtitle() != "") + { + g2.drawString(sh.getCurrentSong().getSubtitle(), 25, 230); + g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260); + g2.drawString(time, 25, 290); + } + else + { + g2.drawString(sh.getCurrentSong().getAuthor(), 25, 230); + g2.drawString(time, 25, 260); + } g2.setColor(Color.YELLOW); g2.fillRect(25, 1000 - 7 * PlayState.comboScore, 200, 0 + 7 * PlayState.comboScore);