added gamestates and started pause screen
This commit is contained in:
@@ -31,7 +31,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
|
||||
// SYSTEM
|
||||
TileManager tileM = new TileManager(this);
|
||||
KeyHandler keyH = new KeyHandler();
|
||||
KeyHandler keyH = new KeyHandler(this);
|
||||
Sound se = new Sound();
|
||||
Sound music = new Sound();
|
||||
public CollisionHandler collisionH = new CollisionHandler(this);
|
||||
@@ -43,6 +43,9 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
public Player player = new Player(this, keyH);
|
||||
public SuperObject[] obj = new SuperObject[10];
|
||||
|
||||
// GAME STATE
|
||||
public GameState gameState;
|
||||
|
||||
public GamePanel() {
|
||||
this.setPreferredSize(new Dimension(screenWidth, screenHeight));
|
||||
this.setBackground(Color.black);
|
||||
@@ -54,6 +57,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
public void setupGame() {
|
||||
assetSetter.setObject();
|
||||
playMusic(0); //Play main theme
|
||||
gameState = GameState.PLAY;
|
||||
}
|
||||
|
||||
public void startGameThread() {
|
||||
@@ -91,7 +95,13 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
player.update();
|
||||
switch(gameState) {
|
||||
case PLAY:
|
||||
player.update();
|
||||
break;
|
||||
case PAUSE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics graphics) {
|
||||
|
||||
Reference in New Issue
Block a user