Exemplo n.º 1
0
  @Override
  public void render(float delta) {
    while (enPause)
      try {
        Thread.sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    // System.out.println(human.getScore());

    ia.play();
    // if (new Random().nextInt() % 300 == 1)
    // entitiesToRender.add(new Gap(1100, 200));

    animTime += Gdx.graphics.getDeltaTime();
    stage.act(delta);
    stage.getSpriteBatch().begin();

    stage.getSpriteBatch().draw(bgSprite, 0, 0);
    bg.render(stage.getSpriteBatch());
    entitiesToRender.removeAll(entitiesToRemove);
    for (Entity entity : entitiesToRender) {
      stage.getSpriteBatch().draw(entity.getFrame(animTime), entity.getX(), entity.getY());
    }
    buchers.render(stage.getSpriteBatch(), animTime);
    stage.getSpriteBatch().draw(tree.getFrame(animTime), tree.getX(), tree.getY());

    if (enPause == true) {
      pause.getSprite().draw(stage.getSpriteBatch());
    }

    score.draw(
        stage.getSpriteBatch(),
        "SCORE : " + GameScreen.getInstance().getHuman().getScore(),
        50,
        50);

    stage.getSpriteBatch().end();

    if (Team.getInstance().allLeaved()) {
      Team.getInstance().reset();
    }
  }
Exemplo n.º 2
0
  private GameScreen() {
    super("img/game/background/bggame.png");
    musique = Gdx.audio.newSound(Gdx.files.internal("sounds/Keyboard-Cat-Song.wav"));
    musique.loop();
    animTime = 0;
    stage = new Stage(960, 640, false);

    bg = new BackGround();
    score = new BitmapFont(Gdx.files.internal("data/game.fnt"));

    buchers = Team.getInstance();
    tree = MovingTree.getInstance();
    human = new Human();
    ia = new IA();
    entitiesToRemove = new HashSet<Entity>();
    pause = new Pause("img/game/background/pause.png");

    stage.addListener(
        new InputListener() {
          public boolean keyDown(InputEvent event, int keyCode) {
            if (keyCode == Input.Keys.RIGHT) {
              human.right();
              return true;
            }
            if (keyCode == Input.Keys.LEFT) {
              human.left();
              return true;
            }
            if (keyCode == Input.Keys.UP) {
              human.up();
              return true;
            }
            if (keyCode == Input.Keys.DOWN) {
              human.down();
              return true;
            }
            /*if (keyCode == Input.Keys.A)
            {
            	changeMode();
            	return true;
            }*/
            return false;
          }
        });
    Gdx.input.setInputProcessor(stage);
    freeEntities();
    // changeMode();
  }
Exemplo n.º 3
0
 public static void resetInstance() {
   Team.resetInstance();
   MovingTree.resetInstance();
   instance = new GameScreen();
 }