Merge remote-tracking branch 'origin/master'

master
Chara1236 2022-06-19 18:10:16 -04:00
commit e8c16f0625
2 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,7 @@ public class FileManager {
o = objectStream.readObject();
objectStream.close();
fileStream.close();
System.out.println("done");
return o;
}

View File

@ -5,6 +5,9 @@ Runs the constructor in GamePanel class
*/
import java.awt.*;
import java.io.IOException;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -25,16 +28,23 @@ public class GameFrame extends JFrame{
main = new CameraPanel();
main.setLayout(new CardLayout());
try {
System.out.println("done2");
game = (GamePanel)FileManager.readObjectFromFile("local/game_state.dat", Arrays.asList("Any"));
game.gameFrame = main;
game.isContinue = true;
game.addUserInterface();
game.startThread();
} catch (IOException | ClassNotFoundException | ClassCastException | SecurityException e) {
System.out.println(e);
game = new GamePanel(main); //run GamePanel constructor
game.startThread();
}
// delete saves to prevent unexpected behaviour
try {
Files.deleteIfExists(Path.of("local/game_state.dat"));
Files.deleteIfExists(Path.of("local/temp_state.dat"));
} catch (FileSystemException e) {
System.out.println(e);
}
game.startThread();
/*
try {
// read previously saved controls