Example #1
0
  public static void main(String[] args) {
    try {
      if (args.length != 2) {
        System.err.println("USAGE: java RenderMap map.txt image.png");
        System.exit(1);
      }
      Game game = new Game(args[0], 100, 0);
      if (game.Init() == 0) {
        System.err.println("Error while loading map " + args[0]);
        System.exit(1);
      }

      ArrayList<Color> colors = new ArrayList<Color>();
      colors.add(new Color(106, 74, 60));
      colors.add(new Color(74, 166, 60));
      colors.add(new Color(204, 51, 63));
      colors.add(new Color(235, 104, 65));
      colors.add(new Color(237, 201, 81));
      Color bgColor = new Color(188, 189, 172);
      Color textColor = Color.BLACK;
      Font planetFont = new Font("Sans Serif", Font.BOLD, 11);
      Font fleetFont = new Font("Sans serif", Font.PLAIN, 7);

      GraphicsConfiguration gc =
          GraphicsEnvironment.getLocalGraphicsEnvironment()
              .getDefaultScreenDevice()
              .getDefaultConfiguration();

      BufferedImage image = gc.createCompatibleImage(640, 480);

      Graphics2D _g = (Graphics2D) image.createGraphics();

      // Turn on AA/Speed
      _g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      _g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
      _g.setRenderingHint(
          RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

      game.Render(640, 480, 0.0, null, colors, bgColor, textColor, planetFont, fleetFont, _g);

      File file = new File(args[1]);
      ImageIO.write(image, "png", file);
    } catch (Exception e) {
      System.err.println(e);
    }
  }
Example #2
0
  @Override
  public void startTheGame() {

    gameType = "";

    try {
      // receive ping from server
      gameType = mainServer.readLine();
    } catch (IOException ex) {
      System.err.println("Could not communicate with server: " + ex);
      Global.onException();
    }

    super.startTheGame();

    for (FixedTimer timer : timers) timer.start();

    startMarquee(getGameType(), 1000);
    startMarquee("3");
    startMarquee("2");
    startMarquee("1");

    // receive ping that the game is starting

    try {
      // ping back that client is ready
      mainServer.println();
      mainServer.flush();
      // wait for if server is ready
      mainServer.readLine();
    } catch (IOException ex) {
      System.err.println("Could not communicate with server: " + ex);
      Global.onException();
    }

    turnOnEndGameReceiver();
    startMarquee("START!");
  }
Example #3
0
 @Override
 public void dispose() {
   closeNetworking();
   super.dispose();
 }
Example #4
0
 @Override
 public void endTheGame(String message) {
   super.endTheGame(message);
   closeNetworking();
   addMenu(new EndGameMenu());
 }