import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; import java.io.IOException; 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; ySpawn = 300; filePath = "saves/Level1.txt"; } else if(level == 2){ xSpawn = 200; ySpawn = 100; filePath = "saves/Level2.txt"; } 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); } }