final/src/LevelManager.java

37 lines
1.1 KiB
Java
Raw Normal View History

2022-06-06 03:18:10 +01:00
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.IOException;
2022-06-05 22:33:24 +01:00
public class LevelManager {
public static int level = 1;
public static int xSpawn = 0;
public static int ySpawn = 600;
public static String filePath;
public static void setLevel(int level){
LevelManager.level = level;
if(level == 1){
xSpawn = 0;
2022-06-06 03:18:10 +01:00
ySpawn = 300;
2022-06-05 22:33:24 +01:00
filePath = "saves/Level1.txt";
} else if(level == 2){
2022-06-06 03:18:10 +01:00
xSpawn = 200;
ySpawn = 100;
2022-06-05 22:33:24 +01:00
filePath = "saves/Level2.txt";
}
2022-06-06 03:18:10 +01:00
try {
MapReader.inputMap(GamePanel.map, GamePanel.enemy,filePath);
} catch (IOException | SpriteException e) {
throw new RuntimeException(e);
} catch (UnsupportedAudioFileException e) {
throw new RuntimeException(e);
} catch (LineUnavailableException e) {
throw new RuntimeException(e);
}
GamePanel.player.reset();
}
public static void nextLevel(){
setLevel(level+1);
2022-06-05 22:33:24 +01:00
}
}