Ejemplo n.º 1
0
  public boolean keyUp(int keycode) {
    if (keycode == Keys.LEFT) controller.leftReleased();

    if (keycode == Keys.RIGHT) controller.rightReleased();

    if (keycode == Keys.Z) controller.jumpReleased();

    if (keycode == Keys.X) controller.fireReleased();

    return true;
  }
Ejemplo n.º 2
0
  public boolean keyDown(int keycode) {
    if (keycode == Keys.LEFT) controller.leftPressed(-1);

    if (keycode == Keys.RIGHT) controller.rightPressed(-1);

    if (keycode == Keys.Z) controller.jumpPressed(-1);

    if (keycode == Keys.X) controller.firePressed(-1);

    if ((keycode == Keys.BACK) || (keycode == Keys.ESCAPE)) {
      finishLevel(ExitBlock.EXIT_NOCLEAR);
    }

    return true;
  }
Ejemplo n.º 3
0
  public boolean touchUp(int x, int y, int pointer, int button) {
    if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
      if (left.contains(x, (y - height) * -1)) {
        controller.leftReleased();
      }

      if (right.contains(x, (y - height) * -1)) {
        controller.rightReleased();
      }

      if (jump.contains(x, (y - height) * -1)) {
        controller.jumpReleased();
      }
      return true;
    }
    return false;
  }
Ejemplo n.º 4
0
  public void show() {
    gameTicks = 0L;

    renderer = new WorldRenderer(world, useGameDebugRenderer);
    controller = new JaxonController(world);
    controller.reset();
    Gdx.input.setInputProcessor(this);

    NerdShooter.shooter.setCurrentScreen(NerdShooter.GAME_SCREEN);
  }
Ejemplo n.º 5
0
  public void render(float delta) {
    gameTicks++;

    long seconds = (long) ((gameTicks / 60D) * 10L);

    Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT);

    controller.update(delta);
    updateEntities(delta);
    renderer.render();

    button.begin(ShapeRenderer.ShapeType.Filled);
    {
      if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
        Gdx.gl.glEnable(Gdx.gl20.GL_BLEND);
        Gdx.gl.glBlendFunc(Gdx.gl20.GL_SRC_ALPHA, Gdx.gl20.GL_ONE_MINUS_SRC_ALPHA);

        button.setColor(0.0F, 0.5F, 0.5F, 0.5F);
        button.rect(left.x, left.y, left.width, left.height);
        button.rect(right.x, right.y, right.width, right.height);

        button.setColor(1.0F, 1.0F, 1.0F, 0.5F);
        button.rect(jump.x, jump.y, jump.width, jump.height);
      }

      world.getJaxon().inventory.renderGUI(button, width, height, buttonSize * 0.75F);
    }
    button.end();

    batch.begin();
    {
      if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
        batch.draw(controlLeft, left.x, left.y, left.width, left.height);
        batch.draw(controlRight, right.x, right.y, right.width, right.height);
        batch.draw(controlUp, jump.x, jump.y, jump.width, jump.height);
      }

      world.getJaxon().inventory.renderItems(batch, width, height, buttonSize * 0.75F);
      font.draw(
          batch,
          "Time: " + (seconds / 10D) + " ticks, FPS: " + Gdx.graphics.getFramesPerSecond(),
          0,
          height - 10);
    }
    batch.end();
  }
Ejemplo n.º 6
0
  public boolean touchDragged(int x, int y, int pointer) {
    if (Gdx.app.getType().equals(Application.ApplicationType.Android)) {
      if (controller.isLeftDown()
          && !left.contains(x, (y - height) * -1)
          && controller.leftPointer == pointer) {
        controller.leftReleased();
      }
      if (controller.isRightDown()
          && !right.contains(x, (y - height) * -1)
          && controller.rightPointer == pointer) {
        controller.rightReleased();
      }
      if (controller.isJumpDown()
          && !jump.contains(x, (y - height) * -1)
          && controller.jumpPointer == pointer) {
        controller.jumpReleased();
      }

      if (!controller.isLeftDown()
          && left.contains(x, (y - height) * -1)
          && controller.leftPointer == -1) {
        controller.leftPressed(pointer);
      }

      if (!controller.isRightDown()
          && right.contains(x, (y - height) * -1)
          && controller.rightPointer == -1) {
        controller.rightPressed(pointer);
      }

      if (!controller.isJumpDown()
          && jump.contains(x, (y - height) * -1)
          && controller.jumpPointer == -1) {
        controller.jumpPressed(pointer);
      }
      return true;
    }
    return false;
  }