Exemplo n.º 1
0
  private void init() {
    try {
      Window.createWindow(width, height, title);
    } catch (Exception e) {
      e.printStackTrace();
    }

    this.renderingEngine = new RenderingEngine();

    game.init();
  }
Exemplo n.º 2
0
Arquivo: Main.java Projeto: ersefa/P2
  /**
   * Main method
   *
   * @param args Execution arguments
   */
  public static void main(String[] args) {

    /** Stream Input/Output configuration */
    streamIn = System.in;
    streamOut = System.out;

    Game game = new Game();
    if (game.init(streamIn, streamOut)) game.runGame();
    else {
      PrintStream ps = new PrintStream(streamOut);
      ps.println("Intitialization Error");
    }
  }
Exemplo n.º 3
0
  @Override
  public void start(Stage s) {
    myGame = new Game();
    s.setTitle(myGame.getTitle());

    Scene scene = myGame.init(WIDTH, HEIGHT);
    s.setScene(scene);

    s.show();

    KeyFrame frame =
        new KeyFrame(Duration.millis(MILLISECOND_DELAY), e -> myGame.step(SECOND_DELAY));
    Timeline animation = new Timeline();
    animation.setCycleCount(Timeline.INDEFINITE);
    animation.getKeyFrames().add(frame);
    animation.play();

    s.setResizable(false);
  }
Exemplo n.º 4
0
  public void run() {
    init();
    long lastTime = System.nanoTime();
    final double amountOfTicks = 60D;
    double ns = 1_000_000_000 / amountOfTicks;
    double delta = 0;

    while (running) {
      long now = System.nanoTime();
      delta += (now - lastTime) / ns;
      lastTime = now;
      // only update 60 times per second
      if (delta >= 1) {
        tick();
        delta--;
      }
      // draw all objects onto screen
      render();
    }
  }
Exemplo n.º 5
0
 public static void main(String[] args) {
   Game game = new Game(500, 500);
   game.init();
 }
Exemplo n.º 6
0
  public void loading(int pos) {
    if (pos == 0) {
      camera = new RTSCamera(getCamera());
      camera.registerWithInput(inputManager);

      loadingScreen.setProgress(0.1f, "Making Light");
    } else if (pos == 1) {

      loadShadow();
      loadLight();

      loadingScreen.setProgress(0.2f, "Loading Terrain");

    } else if (pos == 2) {
      reflectNode = new Node("reflect");
      rootNode.attachChild(reflectNode);
      nonreflectNode = new Node("non reflect");
      rootNode.attachChild(nonreflectNode);

      clickableNode = new Node("clickable");
      reflectNode.attachChild(clickableNode);
      //  clickableNode.attachChild(createTerrain());
      loadTerrain();
      loadWater();

      camera.addTerrain(terrain);
      camera.addWater(water);

      loadingScreen.setProgress(0.6f, "Loading Doodads");
    } else if (pos == 3) {
      loadDoodads();
      loadingScreen.setProgress(0.8f, "Init Game");
    } else if (pos == 4) {

      game.init();

      // gui=new GUI(game);

      game.getMyGame().init(game);

      if (game.isMultiplayer()) {
        client.finishedLoading();
      }

      loadingScreen.setProgress(1f, "Finished Loading");
    } else if (pos == 5) {
      loadingScreen.clear();
      camera.enable();

      gui = new GUI(game);
      gui.init();

      playerInput = new PlayerInput(game);
      // important input after nifty

      next_game_tick = System.currentTimeMillis();

      Timer.init();
      loading = false;
    }
  }
Exemplo n.º 7
0
 private void reset() {
   display.getFrame().dispose();
   // player = new Player(this);
   score1 = score2 = 0;
   init();
 }
Exemplo n.º 8
0
  /** @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */
  public void init(GameContainer container) throws SlickException {
    this.container = container;

    recalculateScale();
    held.init(container);
  }