First bug free game?
This commit is contained in:
+16
-14
@@ -3,13 +3,14 @@ package view;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import model.Player;
|
||||
import control.GameStateManager;
|
||||
import control.LedHandler;
|
||||
|
||||
public class GameView extends JPanel implements ActionListener{
|
||||
@@ -18,14 +19,16 @@ public class GameView extends JPanel implements ActionListener{
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1939480784205689618L;
|
||||
Timer t;
|
||||
Player player;
|
||||
LedHandler led;
|
||||
|
||||
public GameView(LedHandler led)
|
||||
Timer t;
|
||||
LedHandler led;
|
||||
GameStateManager gsm;
|
||||
|
||||
public GameView(LedHandler led,GameStateManager gsm)
|
||||
{
|
||||
this.led=led;
|
||||
t = new Timer(1000/30, this);
|
||||
this.gsm = gsm;
|
||||
t = new Timer(1000/60, this);
|
||||
t.start();
|
||||
setPreferredSize(new Dimension(1280,1024));
|
||||
}
|
||||
@@ -38,13 +41,12 @@ public class GameView extends JPanel implements ActionListener{
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
if(player != null)
|
||||
player.draw(g2d);
|
||||
}
|
||||
|
||||
public void setPlayer(Player player){
|
||||
this.player = player;
|
||||
}
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
RenderingHints rh = new RenderingHints(
|
||||
RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHints(rh);
|
||||
gsm.currentState.draw(g2d);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user