Example #1
0
  @Override
  public void render() {
    try {
      // $$$ Logger.devConsole("" + Gdx.graphics.getFramesPerSecond() + ": " +
      // Gdx.graphics.getDeltaTime());

      // Update
      Input.get().update();
      if (Input.get()
          .isActive(
              sps.bridge.Commands.get(Commands.ToggleDevConsole),
              Client.get().getFirstPlayerIndex())) {
        DevConsole.get().toggle();
      }
      if (Input.get()
          .isActive(sps.bridge.Commands.get(Commands.Back), Client.get().getFirstPlayerIndex())) {
        StateManager.loadState(new MainMenuState());
      }
      if (Input.get()
          .isActive(sps.bridge.Commands.get(Commands.Music), Client.get().getFirstPlayerIndex())) {
        MusicPlayer.get().toggle();
      }
      if (Input.get()
          .isActive(
              sps.bridge.Commands.get(Commands.ToggleFullScreen),
              Client.get().getFirstPlayerIndex())) {
        Renderer.get().toggleFullScreen();
      }

      StateManager.asyncUpdate();

      if (Client.get().nextTurn()) {
        ParticleEngine.update();
        StateManager.update();
        Client.get().prepareForNextTurn();
      } else {
        Client.get().heartBeat();
      }
      if (!IsRunning) {
        System.exit(0);
      }

      TextPool.get().update();

      // Render
      Renderer.get().begin();
      StateManager.draw();
      ParticleEngine.draw();
      HudRenderer.get().draw();
      TextPool.get().draw();
      DevConsole.get().draw();
      Renderer.get().end();
    } catch (Exception e) {
      Logger.exception(e);
    }
  }
Example #2
0
 @Override
 public void create() {
   Sps.setup();
   Renderer.get().setWindowsBackground(Color.BLACK);
   Renderer.get().setStrategy(new FrameStrategy());
   Renderer.get().setRefreshInstance(this);
   Client.reset(new LocalClient());
   Input.get().setup(Client.get());
   SpriteSheetManager.setup(SpriteTypes.getDefs());
   StateManager.loadState(new MainMenuState());
   ParticleEngine.reset();
   MusicPlayer.get(new DefaultMusicPlayer());
   StateManager.loadContent();
 }
  @Override
  public void update() {
    if (readyToConnect && !connectStarted) {
      Client.reset(new LanClient());
      Input.setup(Client.get());
      connectStarted = true;
    }
    if (Input.isActive(Commands.get(Aigilas.Commands.Start), 0)) {
      if (ipIn.getText() != null && !ipIn.getText().isEmpty()) {
        String[] contents = ipIn.getText().split(":");
        String address = contents[0];
        if (contents.length > 1) {
          int port = Parse.inte(contents[1]);
          Config.get().setPort(port);
        }

        label.setText(waitMessage);
        Config.get().setServerIp(address);
        readyToConnect = true;
        ipIn.setVisible(false);
      }
    }
    if (Client.get().isGameStarting()) {
      for (int ii = 0; ii < Client.get().getPlayerCount(); ii++) {
        Input.setContext(Contexts.get(Sps.Contexts.Free), ii);
      }
      StateManager.loadState(new LoadingState());
    }
  }
Example #4
0
 @Override
 public void resize(int width, int height) {
   Renderer.get().resize(width, height);
   StateManager.resize(width, height);
 }