Procházet zdrojové kódy

Menu added and having fun~!

Daniel před 10 roky
rodič
revize
7251d919ae

+ 3 - 2
image/Images.java

@@ -20,7 +20,8 @@ public class Images{
 		  try{
 		   images.add(ImageIO.read(Main.class.getResource("/image/player.png"))); 
 		   images.add(ImageIO.read(Main.class.getResource("/image/player2.png"))); 
-		  
+		   images.add(ImageIO.read(Main.class.getResource("/image/pressstart.png"))); 
+		   
 		  }catch(IOException e){
 		   e.printStackTrace();
 		  }
@@ -33,6 +34,6 @@ public class Images{
 
 	 public enum ImageType
 	 {
-	  player,player2	 
+	  player,player2, pressstart
 	 }
 }

+ 1 - 1
main/Window.java

@@ -64,7 +64,7 @@ public class Window extends JFrame {
 		//Create Instances
 		GameStateManager gsm = new GameStateManager();
 		GameView view = new GameView(led,gsm);
-		GameModel model = new GameModel(view,gsm);
+		GameModel model = new GameModel(gsm);
 		GameControl control = new GameControl(model, view,gsm);
 		setContentPane(view);
 		

+ 43 - 3
model/gameState/MenuState.java

@@ -1,6 +1,12 @@
 package model.gameState;
 
+import image.Images;
+import image.Images.ImageType;
+
+import java.awt.Color;
+import java.awt.Font;
 import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
 
 import control.GameStateManager;
 import control.button.ButtonEvent;
@@ -8,6 +14,11 @@ import control.joystick.JoystickEvent;
 
 public class MenuState extends GameState {
 
+    BufferedImage PressStart = Images.getImage(ImageType.pressstart);
+    int index = 0;
+    int varx = 0;
+    int x,y,frame = 0,maxFrames = 5;
+
 	public MenuState(GameStateManager gsm) {
 		super(gsm);
 	}
@@ -19,14 +30,43 @@ public class MenuState extends GameState {
 
 	@Override
 	public void update() {
-		// TODO Auto-generated method stub
-
+		if(frame == maxFrames-1){
+			 x = (index % 6)*49;
+	         y = 0;
+	
+	         index++;
+	         index %= 6;
+		}
+         frame++;
+         frame %= (maxFrames);
 	}
 
 	@Override
 	public void draw(Graphics2D g2) {
-		g2.drawString("Press 0 to start the game", 1280/2, 1024/2);
+		
+	    g2.setColor(Color.BLACK);    
+		g2.fillRect(0, 0, 1280, 1024);
+		
+		g2.setColor(Color.ORANGE);
+		g2.fillRect(1280/2 -120, 1024/2 - 80, 225, 90);
+		g2.drawRect(1280/2 -122, 1024/2 - 82, 228, 93);
+		
+		g2.translate(1280/2, 1024/2);               
+	        
+	    BufferedImage subImg = PressStart.getSubimage(x, y, 49, 26);
+	    g2.drawImage(subImg, varx - 26*5, 0 - 20*5, 49*5, 26*5, null);
+	
+	    varx+=0;
 
+		Font textFont = new Font("OCR A Extended", Font.BOLD, 15);
+		g2.setFont(textFont);
+		g2.setColor(Color.WHITE);
+		g2.drawString("Copyright 2015 by Daniel Compagner", -180, 500);
+		
+		Font cSFont = new Font("OCR A Extended", Font.BOLD, 100);
+		g2.setFont(cSFont);
+		g2.setColor(Color.GREEN);
+		g2.drawString("Color     Strike", -500, 0);
 	}
 	
 	@Override

+ 1 - 0
model/objects/InfoPanel.java

@@ -34,6 +34,7 @@ public class InfoPanel {
 	}
 	
 	public void draw(Graphics2D g2){
+		g2.setColor(Color.BLACK);
 		g2.fillRect(x, y, 256, 1024);
 		Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
 		g2.setFont(scoreFont);