Kenneth van Ewijk 10 rokov pred
rodič
commit
634451fa20
2 zmenil súbory, kde vykonal 29 pridanie a 28 odobranie
  1. 9 3
      model/GameModel.java
  2. 20 25
      view/GameView.java

+ 9 - 3
model/GameModel.java

@@ -12,6 +12,7 @@ public class GameModel {
 	public static Color[] colors = { Color.GREEN, Color.YELLOW, Color.RED, Color.MAGENTA, Color.CYAN, Color.WHITE };
 	private GameStateManager gsm;
 	private LedHandler led;
+	private int count = 0;
 
 	public GameModel(SongHandler sh, GameStateManager gsm, LedHandler led) {
 		this.gsm = gsm;
@@ -29,10 +30,15 @@ public class GameModel {
 		Color c = colors[(int) (Math.random() * (colors.length - 1) + 1)];
 
 		if (Window.ON_RASP) {
-			for (int i = 7; i < 54; i++) {
-				led.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
+			count++;
+			if(count>15)
+			{
+				for (int i = 7; i < 54; i++) {
+					led.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
+				}
+				led.show();
+				count = 0;
 			}
-			led.show();
 		}
 	}
 }

+ 20 - 25
view/GameView.java

@@ -13,41 +13,36 @@ import javax.swing.JPanel;
 import control.GameStateManager;
 import control.LedHandler;
 
-public class GameView extends JPanel{
-	
+public class GameView extends JPanel {
+
 	/**
 	 * 
 	 */
 	private static final long serialVersionUID = 1939480784205689618L;
-	
-		
+
 	LedHandler led;
 	GameStateManager gsm;
-	Font fpsfont = 	new Font("OCR A Extended", Font.BOLD, 60);
-	
-	public GameView(LedHandler led,GameStateManager gsm)
-	{
-		this.led=led;
-		this.gsm = gsm;		
-		this.
-		setPreferredSize(new Dimension(1280,1024));
+
+	// Font fpsfont = new Font("OCR A Extended", Font.BOLD, 60);
+
+	public GameView(LedHandler led, GameStateManager gsm) {
+		this.led = led;
+		this.gsm = gsm;
+		this.setPreferredSize(new Dimension(1280, 1024));
 	}
 
 	@Override
-	public void paintComponent(Graphics g)
-	{
+	public void paintComponent(Graphics g) {
 		super.paintComponent(g);
-		
+
 		Graphics2D g2d = (Graphics2D) g;
-		RenderingHints rh = new RenderingHints(
-	              RenderingHints.KEY_ANTIALIASING,
-	              RenderingHints.VALUE_ANTIALIAS_ON);
-	     g2d.setRenderingHints(rh);
-		gsm.currentState.draw(g2d);		
-		
-		g2d.setColor(Color.RED);
-		g2d.setFont(fpsfont);
-		g2d.drawString(gsm.fps + "fps", 1000, 40);
+		RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+		g2d.setRenderingHints(rh);
+		gsm.currentState.draw(g2d);
+
+		//g2d.setColor(Color.RED);
+		//g2d.setFont(fpsfont);
+		//g2d.drawString(gsm.fps + "fps", 1000, 40);
 		Toolkit.getDefaultToolkit().sync();
-	}	
+	}
 }