Exemple #1
0
  public GameScreen(MainWindow game, String levelName, boolean activateLights) {
    this.game = game;

    this.levelName = levelName;

    showGameOverScreen = false;

    this.activateLights = activateLights;

    Gdx.app.setLogLevel(Application.LOG_DEBUG);

    debugRenderer = new Box2DDebugRenderer();

    worldLoader = new WorldLoader(game, this);

    camera = new Cameras(game, worldLoader, game.getBatch());

    multiplexer = new InputMultiplexer();

    multiplexer.addProcessor(camera.getHudStage());
    multiplexer.addProcessor(worldLoader.getControls());

    Gdx.input.setInputProcessor(multiplexer);

    gameMiddleground = null;

    chooseBackground();
  }
Exemple #2
0
 @Override
 public void dispose() {
   worldLoader.dispose();
   debugRenderer.dispose();
   camera.dispose();
   game.dispose();
 }
Exemple #3
0
  @Override
  public void render(float delta) {
    // Reinigt Bildschirm
    Gdx.gl.glClearColor(0.9f, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Aktualisiert Logik
    worldLoader.getRenderer().setView(camera.getPlayerCamera());
    worldLoader.updateWorld(delta);

    // Rendert alle Objeckte innerhalb des batchs
    game.getBatch().begin();
    game.getBatch().setProjectionMatrix(camera.getBackgroundCamera().combined);
    game.getBatch()
        .draw(
            gameBackground,
            -15,
            -10,
            gameBackground.getWidth() / 40,
            gameBackground.getHeight() / 30);
    game.getBatch()
        .draw(
            gameBackground,
            -15 + gameBackground.getWidth() / 40,
            -10,
            gameBackground.getWidth() / 40,
            gameBackground.getHeight() / 30,
            0,
            0,
            gameBackground.getWidth(),
            gameBackground.getHeight(),
            true,
            false);
    if (gameMiddleground != null) {
      game.getBatch().setProjectionMatrix(camera.getMiddlegroundCamera().combined);
      game.getBatch()
          .draw(
              gameMiddleground,
              -15,
              -10,
              gameBackground.getWidth() / 40,
              gameBackground.getHeight() / 30);
      game.getBatch()
          .draw(
              gameMiddleground,
              -15 + gameBackground.getWidth() / 40,
              -10f,
              gameBackground.getWidth() / 40,
              gameBackground.getHeight() / 30,
              0,
              0,
              gameBackground.getWidth(),
              gameBackground.getHeight(),
              true,
              false);
    }

    game.getBatch().end();

    camera.update(delta);
    // Rendert tmx map
    game.getBatch().setProjectionMatrix(camera.getPlayerCamera().combined);
    worldLoader.renderMap(game.getBatch());

    // Rendert Physik-Debug Texturen
    // debugRenderer.render(worldLoader.getWorld(), camera.getPlayerCamera().combined);

    if (showGameOverScreen == true) {
      // camera.getGameOverStage().getBatch().setColor(Color.RED);
      game.getBatch().begin();
      game.getBatch().setColor(0.9f, 0.1f, 0.1f, 0.6f);
      /*
      game.getBatch().draw(game.getAssets().getWhiteColor(),0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
      */
      game.getBatch().end();
      camera.getGameOverStage().draw();

    } else if (showMenuScreen == true) {
      camera.getMenuStage().draw();
    } else if (showGameEndScreen == true) {
      camera.getGameEndStage().draw();
    } else {
      camera.render(game.getBatch());
    }
  }