From a6e1ffe98c8ae8c8095e597b28ccd3565818207c Mon Sep 17 00:00:00 2001 From: bob Date: Sun, 12 Jun 2022 18:22:13 -0400 Subject: [PATCH] Some comments --- src/BackgroundImage.java | 1 + src/Camera.java | 4 +++- src/FileManager.java | 2 ++ src/MapReader.java | 4 ++-- src/MenuPanel.java | 2 +- src/Player.java | 12 +++++------- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/BackgroundImage.java b/src/BackgroundImage.java index 0cdaa8d..6dd1a73 100644 --- a/src/BackgroundImage.java +++ b/src/BackgroundImage.java @@ -1,3 +1,4 @@ +//The purpose of this class is to create a background which acts as a parallax import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; diff --git a/src/Camera.java b/src/Camera.java index 5f84198..ca5279b 100644 --- a/src/Camera.java +++ b/src/Camera.java @@ -1,4 +1,6 @@ - +//This class controls the x-scrolling aspect for the player +//If you look at the players absolute position(Relative to the screen), the players y position changes, but the x position +//never actually changes. public class Camera { public int x; public Camera(int x){ diff --git a/src/FileManager.java b/src/FileManager.java index aefa63f..467490c 100644 --- a/src/FileManager.java +++ b/src/FileManager.java @@ -1,3 +1,5 @@ +//This class allows us to input and output flies useful for +//Inputing levels and making save data. import java.io.*; import java.util.Scanner; diff --git a/src/MapReader.java b/src/MapReader.java index 88de8c2..0c82583 100644 --- a/src/MapReader.java +++ b/src/MapReader.java @@ -4,8 +4,8 @@ import java.io.*; import java.util.Arrays; public class MapReader { - private static int x = 0; - private static int y = 0; + public static int x = 0; + public static int y = 0; public static int TileX = 0; public static int TileY = 0; //Input game map diff --git a/src/MenuPanel.java b/src/MenuPanel.java index 9880935..a7ab6ca 100644 --- a/src/MenuPanel.java +++ b/src/MenuPanel.java @@ -43,7 +43,7 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{ this.gameFrame = gameFrame; camera = gameFrame.camera; - title = new TextBox(100, 400, 100, GAME_WIDTH, standardFont, "Placeholder", null); + title = new TextBox(100, 400, 100, GAME_WIDTH, standardFont, "Platformer", null); enter = new TextBox(300, 600, 100, GAME_WIDTH, standardFont, "Start Game", "game"); settings = new TextBox(400, 600, 100, GAME_WIDTH, standardFont, "Settings", "settings"); textBoxArray.add(enter); diff --git a/src/Player.java b/src/Player.java index 8d3a8ea..1af1dfa 100644 --- a/src/Player.java +++ b/src/Player.java @@ -223,23 +223,21 @@ public class Player extends GenericSprite { if(e.getButton()==MouseEvent.BUTTON3) { int x = (mouseX + GamePanel.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length; int y = (mouseY / Tile.length); - if (GamePanel.map[x][y] != null) { - if (!holdingSteel) { + + if (!holdingSteel&&GamePanel.map[x][y] != null) { rightMouseDown = true; if (GamePanel.map[x][y].movable) { holdingSteel = true; GamePanel.map[x][y] = null; } - } else { + } else if(GamePanel.map[x][y] == null){ holdingSteel = false; - MapReader.TileX = x; - MapReader.TileY = y; - MapReader.newTile("img/tiles/boxes/steel.png"); + GamePanel.map[x][y] = new SingleTile(x*Tile.length - (GamePanel.GAME_WIDTH/2), y*Tile.length, GamePanel.getImage("img/tiles/boxes/steel.png")); GamePanel.map[x][y].movable = true; } } } - } + public void mouseDragged(MouseEvent e) {