From 30779b1cc08e8063e8db51be62c6af718526d572 Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 14 Jun 2022 13:34:18 -0400 Subject: [PATCH] WOrking o n steel --- src/GamePanel.java | 3 +-- src/MenuPanel.java | 6 ++++++ src/Player.java | 41 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/GamePanel.java b/src/GamePanel.java index fc1feac..ba4cb77 100644 --- a/src/GamePanel.java +++ b/src/GamePanel.java @@ -298,7 +298,6 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{ //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); - //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; @@ -313,7 +312,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{ //only move objects around and update screen if enough time has passed if(delta >= 1){ - if (!isPaused) { + if (!isPaused && MenuPanel.gameStart) { // only perform game functions if game is not paused try { move(); diff --git a/src/MenuPanel.java b/src/MenuPanel.java index a7ab6ca..189976e 100644 --- a/src/MenuPanel.java +++ b/src/MenuPanel.java @@ -36,6 +36,8 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{ // keeps track of how many ticks has elapsed since last frame change public int currentBox = 0; + public static boolean gameStart = false; + // image imports begin here public BufferedImage backgroundImage = GamePanel.getImage("img/backgrounds/pointyMountains.png"); @@ -145,8 +147,12 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{ //if a key is pressed, we'll send it over to the Player class for processing public void keyPressed(KeyEvent e) { + e = UtilityFunction.intercept(e, GamePanel.middlewareArray); if (e.getKeyCode() == KeyEvent.VK_ENTER) { + if(textBoxArray.get(currentBox).id.equals("game")){ + gameStart = true; + } // logic for different screens starts here CardLayout cardLayout = (CardLayout) gameFrame.getLayout(); cardLayout.show(gameFrame, textBoxArray.get(currentBox).id); diff --git a/src/Player.java b/src/Player.java index e11778f..2cf17a9 100644 --- a/src/Player.java +++ b/src/Player.java @@ -127,9 +127,40 @@ public class Player extends GenericSprite { } return canUpdate; } + +// public boolean SteelCollide(GenericSprite g, int x, int y){ +// if(x+WIDTH>tile.realX&&x