diff --git a/src/GamePanel.java b/src/GamePanel.java index fc38571..7d8dfb1 100644 --- a/src/GamePanel.java +++ b/src/GamePanel.java @@ -224,9 +224,9 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ } else { filePath = "img/tiles/boxes/redSteel.png"; } - double x = ((player.mouseX-(Tile.length/2)) / Tile.length)*Tile.length + (camera.x/Tile.length)*Tile.length; + int x = (player.mouseX + camera.x + GAME_WIDTH / 2) / Tile.length; double y = ((player.mouseY / Tile.length))*Tile.length; - g.drawImage(getImage(filePath),(int)x-camera.x+Tile.length/2+1,(int)y,Tile.length,Tile.length,null); + g.drawImage(getImage(filePath),x*Tile.length - (GamePanel.GAME_WIDTH/2)-camera.x,(int)y,Tile.length,Tile.length,null); } // g.drawString(camera.x+" "+((camera.x+GAME_WIDTH)/Tile.length)+" "+player.leftMouseDown,100,100); @@ -299,7 +299,6 @@ 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); - //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; @@ -314,7 +313,7 @@ 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) { + if (!isPaused && MenuPanel.gameStart) { // only perform game functions if game is not paused try { move(); diff --git a/src/MapReader.java b/src/MapReader.java index 0c82583..6cfa628 100644 --- a/src/MapReader.java +++ b/src/MapReader.java @@ -87,6 +87,7 @@ public class MapReader { } else if(file.charAt(i)=='v'){ newTile("img/tiles/background/wall.png"); GamePanel.map[x][y].collision = false; + GamePanel.map[x][y].replaceAble = true; } else if(file.charAt(i)=='l'){ newTile("img/tiles/terrain/lava.png"); GamePanel.map[x][y].nonBombCollide = true; 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 b4a3f6a..2cf17a9 100644 --- a/src/Player.java +++ b/src/Player.java @@ -15,6 +15,8 @@ public class Player extends GenericSprite { public final int SPEED = 5; public static final int PLAYER_WIDTH = 52; public static final int PLAYER_HEIGHT = 94; + + public static final int steelReachRange = 3*Tile.length; public int lastXDirection, lastYDirection, lastFrame; public int upKey, downKey, rightKey, leftKey; @@ -125,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