Finish DialogueMenu

master
John 2022-06-15 14:55:39 -04:00
parent 913b742a18
commit 6a2d2361c7
1 changed files with 8 additions and 4 deletions

View File

@ -65,6 +65,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
public BufferedImageWrapper cloud2 = new BufferedImageWrapper(getImage("img/backgrounds/cloud2.png"));
public BufferedImageWrapper cloud3 = new BufferedImageWrapper(getImage("img/backgrounds/cloud3.png"));
public BufferedImageWrapper bomb;
public BufferedImageWrapper onePortrait = new BufferedImageWrapper(getImage("img/dialogue/Gunther.png"));
public GamePanel(JPanel gameFrame) throws IOException, SpriteException, UnsupportedAudioFileException, LineUnavailableException {
@ -75,7 +76,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
cloudTwoBackground = new BackgroundImage(600, 250, cloud2, cloud2.image.getWidth(), cloud3.image.getHeight(), 5, camera);
cloudThreeBackground = new BackgroundImage(1000, 200, cloud3, cloud2.image.getWidth(), cloud3.image.getHeight(), 5, camera);
pauseMenu = new PauseMenu(GAME_HEIGHT/2, 100, 400, 400, GAME_WIDTH, new Font(Font.MONOSPACED, Font.BOLD, 60), "Paused");
dialogueMenu = new DialogueMenu(0, 200, new Font(Font.MONOSPACED, Font.BOLD, 60));
dialogueMenu = new DialogueMenu(GAME_HEIGHT-100, 200, new Font(Font.MONOSPACED, Font.BOLD, 20), onePortrait);
try {
// load player sprites from disk here
for (int i = 0; i < 11; i++) {
@ -181,7 +182,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
cloudOneBackground.draw(g);
cloudTwoBackground.draw(g);
cloudThreeBackground.draw(g);
if (isPaused) {
if (isPaused || isDialogue) {
// set player frame to 0 to prevent frame from changing when player moves
playerFrame = 0;
Graphics2D g2d = (Graphics2D)(g);
@ -316,6 +317,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
//run() method is what makes the game continue running without end. It calls other methods to move objects, check for collision, and update the screen
public void run(){
LevelManager.setLevel(1);
isDialogue = 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.
long lastTime = System.nanoTime();
double amountOfTicks = 60;
@ -330,8 +332,8 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
//only move objects around and update screen if enough time has passed
if(delta >= 1){
if (!isPaused && MenuPanel.gameStart) {
// only perform game functions if game is not paused
if ((!isPaused && !isDialogue) && MenuPanel.gameStart) {
// only perform game functions if game is not paused or in dialogue
try {
move();
} catch (IOException e) {
@ -388,6 +390,8 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
e = UtilityFunction.intercept(e, middlewareArray);
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
isPaused = !isPaused;
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
isDialogue = false;
} else {
player.keyPressed(e);
}