package edu.ups.gamedev.examples.six;
import java.net.InetAddress;
import javax.swing.JFrame;
import com.jmex.editors.swing.settings.GameSettingsPanel;
import com.jmex.game.StandardGame;
import com.jmex.game.state.GameStateManager;
import edu.ups.gamedev.game.TankGame;
import edu.ups.gamedev.ui.NetworkPanel;
public class StandardGameExample {
private static boolean runServer = false; //run a server if true, run a client if false
private static InetAddress serverAddress;
public static void main(String[] args) throws Exception {
askRunServer();
StandardGame game = new StandardGame("StandardGameExample");
TankGame.GAME = game;
GameSettingsPanel.prompt(game.getSettings());
game.start();
NetworkTanksState tankStates = new NetworkTanksState(runServer, serverAddress);
GameStateManager.getInstance().attachChild(tankStates);
tankStates.setActive(true);
}
/**
* Queries the user for whether or not to run in server mode.
*/
private static void askRunServer() {
NetworkPanel netPan;
netPan = new NetworkPanel();
JFrame frame = new JFrame();
frame.add(netPan);
frame.pack();
frame.setVisible(true);
runServer = netPan.isServer();
serverAddress = netPan.getServerAddress();
frame.setVisible(false);
}
}