|
|
|
@ -19,6 +19,7 @@ import com.msb.model.abstracts.BaseExplode;
|
|
|
|
|
import com.msb.model.abstracts.GameObject;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -126,4 +127,29 @@ public class GameModel {
|
|
|
|
|
public void remove(GameObject gameObject) {
|
|
|
|
|
gameObjects.remove(gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void save() {
|
|
|
|
|
File file = new File("F:\\bingor\\temp\\tank.data");
|
|
|
|
|
try {
|
|
|
|
|
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
|
|
|
|
|
oos.writeObject(myTank);
|
|
|
|
|
oos.writeObject(gameObjects);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void load() {
|
|
|
|
|
File file = new File("F:\\bingor\\temp\\tank.data");
|
|
|
|
|
ObjectInputStream ois = null;
|
|
|
|
|
try {
|
|
|
|
|
ois = new ObjectInputStream(new FileInputStream(file));
|
|
|
|
|
myTank = (Tank) ois.readObject();
|
|
|
|
|
gameObjects = (List<GameObject>) ois.readObject();
|
|
|
|
|
} catch (IOException | ClassNotFoundException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|