Преглед на файлове

Objects stop on song end.
Added time and song name.
Changed WHITE to ORANGE.

Kenneth van Ewijk преди 10 години
родител
ревизия
136d9fe2cf
променени са 5 файла, в които са добавени 49 реда и са изтрити 6 реда
  1. 5 0
      audio/SongInstance.java
  2. 1 1
      model/GameModel.java
  3. 6 0
      model/gameState/MenuState.java
  4. 4 1
      model/gameState/PlayState.java
  5. 33 4
      model/objects/InfoPanel.java

+ 5 - 0
audio/SongInstance.java

@@ -61,6 +61,11 @@ public class SongInstance {
 		return b;
 	}
 	
+	public long getEndTime()
+	{
+		return objects.get(objects.size()-1).getTime();
+	}
+	
 	public List<ButtonInstance> getButtonsBetween(long oldProgress, long progress) {
 		List<ButtonInstance> b = new ArrayList<ButtonInstance>();
 		

+ 1 - 1
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;

+ 6 - 0
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) {

+ 4 - 1
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;
 

+ 33 - 4
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);