Merge remote-tracking branch 'origin/master'

master
Chara1236 2022-06-19 17:23:36 -04:00
commit cf134e3104
4 changed files with 19 additions and 12 deletions

View File

@ -412,7 +412,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
double delta = 0;
long now;
int fireballCounter = 0;
while(true){ //this is the infinite game loop
while(isRunning){ //this is the infinite game loop
now = System.nanoTime();
delta = delta + (now-lastTime)/ns;
lastTime = now;

View File

@ -14,7 +14,7 @@ public class LevelManager implements Serializable {
public static String filePath;
public static int bombs;
public static void setLevel(int level){
public static void setLevel(int level, boolean hasDied){
GameFrame.game.bombs.clear();
GameFrame.game.fireballs.clear();
GameFrame.game.player.yVelocity = 0;
@ -38,6 +38,7 @@ public class LevelManager implements Serializable {
}
try {
MapReader.inputMap(filePath);
if (!hasDied) {
GameFrame.game.dialogueArray = new ArrayList<String>(Arrays.asList(MapReader.inputDialogue(filePath)));
if (GameFrame.game.dialogueArray.get(0).contains("$Villain")) {
GameFrame.game.dialogueArray.remove(0);
@ -48,11 +49,16 @@ public class LevelManager implements Serializable {
GameFrame.game.dialogueMenu.currentFrame = 0;
GameFrame.game.dialogueMenu.frameCounter = 0;
GameFrame.game.isDialogue = true;
}
} catch (IOException | SpriteException | UnsupportedAudioFileException | LineUnavailableException e) {
throw new RuntimeException(e);
}
//GamePanel.player.reset();
}
public static void setLevel(int level) {
setLevel(level, false);
}
public static void nextLevel(){
setLevel(level+1);
}

View File

@ -168,6 +168,7 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{
GameFrame.game.isRunning = false;
GameFrame.game.player.xVelocity = 0;
GameFrame.game.player.yVelocity = 0;
GameFrame.game.map = new Tile[1000][18];
GameFrame.game = new GamePanel(GameFrame.main); //run GamePanel constructor
GameFrame.game.startThread();
GameFrame.main.add(GameFrame.game, "game", 0);

View File

@ -282,7 +282,7 @@ public class Player extends GenericSprite {
}
public void reset(){
LevelManager.setLevel(LevelManager.level);
LevelManager.setLevel(LevelManager.level, true);
GameFrame.game.camera.x = LevelManager.xSpawn;
y = LevelManager.ySpawn;
holdingSteel = false;