66 lines
2.1 KiB
Java
66 lines
2.1 KiB
Java
package electrosphere.util.worldviewer;
|
|
|
|
import com.google.gson.Gson;
|
|
import electrosphere.game.state.MacroSimulation;
|
|
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
import electrosphere.game.server.terrain.models.TerrainModel;
|
|
import electrosphere.main.Globals;
|
|
import electrosphere.main.Main;
|
|
import electrosphere.util.FileLoadingUtils;
|
|
import electrosphere.util.Utilities;
|
|
import java.awt.Color;
|
|
import java.awt.Graphics;
|
|
import java.awt.event.KeyEvent;
|
|
import java.awt.event.KeyListener;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.Random;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import javax.swing.JComponent;
|
|
import javax.swing.JFrame;
|
|
|
|
/**
|
|
*
|
|
* @author amaterasu
|
|
*/
|
|
public class TerrainViewer {
|
|
|
|
|
|
public static void runViewer(){
|
|
|
|
TerrainModel terrainModel;
|
|
|
|
// ServerTerrainManager terrainManager = new ServerTerrainManager(2000, 1000, 100, 0.05f, new Random().nextLong());
|
|
// terrainManager.generate();
|
|
// terrainModel = terrainManager.getModel();
|
|
|
|
// Utilities.saveObjectToBakedJsonFile("/Config/testingTerrain.json", terrainModel);
|
|
terrainModel = FileLoadingUtils.loadObjectFromAssetPath("/Config/testingTerrain.json", TerrainModel.class);
|
|
|
|
MacroSimulation simulation = new MacroSimulation();
|
|
|
|
JFrame frame = new JFrame();
|
|
TerrainViewerJComponent jComponent = new TerrainViewerJComponent(terrainModel);
|
|
frame.add(jComponent);
|
|
frame.addKeyListener(new TerrainViewerKeyListener(jComponent));
|
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
frame.setBounds(0, 0, 1050, 1050);
|
|
frame.setVisible(true);
|
|
|
|
while(true){
|
|
frame.repaint();
|
|
simulation.simulate();
|
|
try {
|
|
TimeUnit.MILLISECONDS.sleep(10);
|
|
} catch (InterruptedException ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|