Unstatic everything to fix bug

master
John 2022-06-20 14:53:31 -04:00
parent b8120fa64f
commit 1c3cecb6e3
1 changed files with 30 additions and 32 deletions

View File

@ -5,10 +5,6 @@ import java.util.ArrayList;
import java.util.Arrays;
public class MapReader implements Serializable {
public static int x = 0;
public static int y = 0;
public static int TileX = 0;
public static int TileY = 0;
//Input game map
/*
1: Normal Grass
@ -27,8 +23,10 @@ public class MapReader implements Serializable {
// h k Shooting
// m
public static void inputMap(String filePath) throws IOException, SpriteException, UnsupportedAudioFileException, LineUnavailableException {
x = 0;
y = 0;
int x = 0;
int y = 0;
int TileX = 0;
int TileY = 0;
GameFrame.game.enemy.clear();
GameFrame.game.particleTiles.clear();
GameFrame.game.shootingTiles.clear();
@ -48,75 +46,75 @@ public class MapReader implements Serializable {
}
TileY = y*Tile.length;
if(file.charAt(i)=='1'){
newTile("img/tiles/terrain/grass.png");
newTile("img/tiles/terrain/grass.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='2'){
newTile("img/tiles/terrain/grassLeft.png");
newTile("img/tiles/terrain/grassLeft.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='3'){
newTile("img/tiles/terrain/grassRight.png");
newTile("img/tiles/terrain/grassRight.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='q'){
newTile("img/tiles/terrain/grassTopLeft.png");
newTile("img/tiles/terrain/grassTopLeft.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='w'){
newTile("img/tiles/terrain/grassMid.png");
newTile("img/tiles/terrain/grassMid.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='e'){
newTile("img/tiles/terrain/grassTopRight.png");
newTile("img/tiles/terrain/grassTopRight.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='a'){
newTile("img/tiles/terrain/grassMiddleLeft.png");
newTile("img/tiles/terrain/grassMiddleLeft.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='s'){
newTile("img/tiles/terrain/grassCenter.png");
newTile("img/tiles/terrain/grassCenter.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='d'){
newTile("img/tiles/terrain/grassMiddleRight.png");
newTile("img/tiles/terrain/grassMiddleRight.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='z'){
newTile("img/tiles/terrain/grassBottomLeft.png");
newTile("img/tiles/terrain/grassBottomLeft.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='x'){
newTile("img/tiles/terrain/grassBottomMiddle.png");
newTile("img/tiles/terrain/grassBottomMiddle.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='c'){
newTile("img/tiles/terrain/grassBottomRight.png");
newTile("img/tiles/terrain/grassBottomRight.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='r'){
newTile("img/tiles/terrain/cornerTopLeft.png");
newTile("img/tiles/terrain/cornerTopLeft.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='t'){
newTile("img/tiles/terrain/cornerTopRight.png");
newTile("img/tiles/terrain/cornerTopRight.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='f'){
newTile("img/tiles/terrain/cornerBottomLeft.png");
newTile("img/tiles/terrain/cornerBottomLeft.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='g'){
newTile("img/tiles/terrain/cornerBottomRight.png");
newTile("img/tiles/terrain/cornerBottomRight.png", x, y, TileX, TileY);
} else if(file.charAt(i)=='b'){
newTile("img/tiles/boxes/box.png");
newTile("img/tiles/boxes/box.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].breakable = true;
} else if(file.charAt(i)=='!'){
GameFrame.game.enemy.add(new NonPlayer(TileX, TileY, GameFrame.game.slimeSpriteArray, 50, 28, 100));
} else if(file.charAt(i)=='+') {
newTile("img/tiles/boxes/finish.png");
newTile("img/tiles/boxes/finish.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].isFinish = true;
GameFrame.game.map[x][y].nonBombCollide = true;
} else if(file.charAt(i)=='v'){
newTile("img/tiles/background/wall.png");
newTile("img/tiles/background/wall.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].collision = false;
GameFrame.game.map[x][y].replaceAble = true;
} else if(file.charAt(i)=='l'){
newTile("img/tiles/terrain/lava.png");
newTile("img/tiles/terrain/lava.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].nonBombCollide = true;
GameFrame.game.map[x][y].kills = true;
if(y>0&&GameFrame.game.map[x][y-1]==null) {
GameFrame.game.particleTiles.add(GameFrame.game.map[x][y]);
}
} else if(file.charAt(i)=='o'){
newTile("img/tiles/boxes/steel.png");
newTile("img/tiles/boxes/steel.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].movable = true;
} else if(file.charAt(i)=='h'){
newTile("img/tiles/boxes/boxShootLeft.png");
newTile("img/tiles/boxes/boxShootLeft.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].shootingDir = "left";
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
} else if(file.charAt(i)=='u'){
newTile("img/tiles/boxes/boxShootUp.png");
newTile("img/tiles/boxes/boxShootUp.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].shootingDir = "up";
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
} else if(file.charAt(i)=='k'){
newTile("img/tiles/boxes/boxShootRight.png");
newTile("img/tiles/boxes/boxShootRight.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].shootingDir = "right";
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
} else if(file.charAt(i)=='m'){
newTile("img/tiles/boxes/boxShootDown.png");
newTile("img/tiles/boxes/boxShootDown.png", x, y, TileX, TileY);
GameFrame.game.map[x][y].shootingDir = "down";
GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]);
}
@ -139,7 +137,7 @@ public class MapReader implements Serializable {
return returnArray;
}
public static void newTile(String filePath) throws IOException, SpriteException {
public static void newTile(String filePath, int x, int y, int TileX, int TileY) throws IOException, SpriteException {
GameFrame.game.map[x][y]=(new SingleTile(TileX,TileY, new BufferedImageWrapper((filePath))));
}
}