Fix p, add loading screen
parent
af47165a4a
commit
0f39c42006
|
@ -37,6 +37,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
public static Font loreFont = new Font(Font.MONOSPACED, Font.ITALIC + Font.BOLD, 36);
|
public static Font loreFont = new Font(Font.MONOSPACED, Font.ITALIC + Font.BOLD, 36);
|
||||||
public static Color tutorialColor = Color.darkGray;
|
public static Color tutorialColor = Color.darkGray;
|
||||||
public static Color loreColor = Color.lightGray;
|
public static Color loreColor = Color.lightGray;
|
||||||
|
public PauseMenu loadingMenu;
|
||||||
|
|
||||||
public int bombCount;
|
public int bombCount;
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
public boolean isRunning;
|
public boolean isRunning;
|
||||||
public ArrayList<WallSign> tutorialSign = new ArrayList<WallSign>();
|
public ArrayList<WallSign> tutorialSign = new ArrayList<WallSign>();
|
||||||
public ArrayList<WallSign> loreSign = new ArrayList<WallSign>();
|
public ArrayList<WallSign> loreSign = new ArrayList<WallSign>();
|
||||||
|
public boolean isLoaded;
|
||||||
|
|
||||||
|
|
||||||
public GamePanel(JPanel gameFrame) throws IOException, SpriteException, UnsupportedAudioFileException, LineUnavailableException {
|
public GamePanel(JPanel gameFrame) throws IOException, SpriteException, UnsupportedAudioFileException, LineUnavailableException {
|
||||||
|
@ -107,6 +109,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
pauseMenuExitOne = new PauseMenu(GAME_HEIGHT/2, 0, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 24), "Press ENTER to return", true);
|
pauseMenuExitOne = new PauseMenu(GAME_HEIGHT/2, 0, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 24), "Press ENTER to return", true);
|
||||||
pauseMenuExitTwo = new PauseMenu(GAME_HEIGHT/2, -20, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 24), "to the main menu", true);
|
pauseMenuExitTwo = new PauseMenu(GAME_HEIGHT/2, -20, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 24), "to the main menu", true);
|
||||||
pauseMenuResume = new PauseMenu(GAME_HEIGHT/2, -50, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 18), "(or press ESC to resume)", true);
|
pauseMenuResume = new PauseMenu(GAME_HEIGHT/2, -50, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 18), "(or press ESC to resume)", true);
|
||||||
|
loadingMenu = new PauseMenu(GAME_HEIGHT/2, 0, GAME_WIDTH, GAME_HEIGHT, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 60), "Loading...", true);
|
||||||
dialogueMenu = new DialogueMenu(GAME_HEIGHT-100, 200, new Font(Font.MONOSPACED, Font.BOLD, 20), narratorPortrait, true);
|
dialogueMenu = new DialogueMenu(GAME_HEIGHT-100, 200, new Font(Font.MONOSPACED, Font.BOLD, 20), narratorPortrait, true);
|
||||||
try {
|
try {
|
||||||
// load player sprites from disk here
|
// load player sprites from disk here
|
||||||
|
@ -355,6 +358,9 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
// throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isLoaded) {
|
||||||
|
loadingMenu.draw(g, Color.white, Color.black);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//call the move methods in other classes to update positions
|
//call the move methods in other classes to update positions
|
||||||
|
@ -433,6 +439,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
} else {
|
} else {
|
||||||
LevelManager.bombs = bombCount;
|
LevelManager.bombs = bombCount;
|
||||||
}
|
}
|
||||||
|
isLoaded = true;
|
||||||
//the CPU runs our game code too quickly - we need to slow it down! The following lines of code "force" the computer to get stuck in a loop for short intervals between calling other methods to update the screen.
|
//the CPU runs our game code too quickly - we need to slow it down! The following lines of code "force" the computer to get stuck in a loop for short intervals between calling other methods to update the screen.
|
||||||
long lastTime = System.nanoTime();
|
long lastTime = System.nanoTime();
|
||||||
double amountOfTicks = 60;
|
double amountOfTicks = 60;
|
||||||
|
@ -564,7 +571,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
player.keyReleased(e);
|
player.keyReleased(e);
|
||||||
if(e.getKeyChar() == 'p'){
|
if(e.getKeyChar() == 'p'){
|
||||||
LevelManager.nextLevel();
|
LevelManager.nextLevel();
|
||||||
|
try {
|
||||||
|
player.resetNoSound();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue