Some comments

master
bob 2022-06-12 18:22:13 -04:00
parent 1c3ae30225
commit a6e1ffe98c
6 changed files with 14 additions and 11 deletions

View File

@ -1,3 +1,4 @@
//The purpose of this class is to create a background which acts as a parallax
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;

View File

@ -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 class Camera {
public int x; public int x;
public Camera(int x){ public Camera(int x){

View File

@ -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.io.*;
import java.util.Scanner; import java.util.Scanner;

View File

@ -4,8 +4,8 @@ import java.io.*;
import java.util.Arrays; import java.util.Arrays;
public class MapReader { public class MapReader {
private static int x = 0; public static int x = 0;
private static int y = 0; public static int y = 0;
public static int TileX = 0; public static int TileX = 0;
public static int TileY = 0; public static int TileY = 0;
//Input game map //Input game map

View File

@ -43,7 +43,7 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{
this.gameFrame = gameFrame; this.gameFrame = gameFrame;
camera = gameFrame.camera; 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"); enter = new TextBox(300, 600, 100, GAME_WIDTH, standardFont, "Start Game", "game");
settings = new TextBox(400, 600, 100, GAME_WIDTH, standardFont, "Settings", "settings"); settings = new TextBox(400, 600, 100, GAME_WIDTH, standardFont, "Settings", "settings");
textBoxArray.add(enter); textBoxArray.add(enter);

View File

@ -223,23 +223,21 @@ public class Player extends GenericSprite {
if(e.getButton()==MouseEvent.BUTTON3) { if(e.getButton()==MouseEvent.BUTTON3) {
int x = (mouseX + GamePanel.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length; int x = (mouseX + GamePanel.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
int y = (mouseY / Tile.length); int y = (mouseY / Tile.length);
if (GamePanel.map[x][y] != null) {
if (!holdingSteel) { if (!holdingSteel&&GamePanel.map[x][y] != null) {
rightMouseDown = true; rightMouseDown = true;
if (GamePanel.map[x][y].movable) { if (GamePanel.map[x][y].movable) {
holdingSteel = true; holdingSteel = true;
GamePanel.map[x][y] = null; GamePanel.map[x][y] = null;
} }
} else { } else if(GamePanel.map[x][y] == null){
holdingSteel = false; holdingSteel = false;
MapReader.TileX = x; GamePanel.map[x][y] = new SingleTile(x*Tile.length - (GamePanel.GAME_WIDTH/2), y*Tile.length, GamePanel.getImage("img/tiles/boxes/steel.png"));
MapReader.TileY = y;
MapReader.newTile("img/tiles/boxes/steel.png");
GamePanel.map[x][y].movable = true; GamePanel.map[x][y].movable = true;
} }
} }
} }
}
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {