Exemplo n.º 1
0
  private void draw() {
    if (disposed) return;
    batch.setProjectionMatrix(camera.combined);
    batch.begin();

    if (!set_buttons && !set_keys) {
      tilemap.draw(batch, camera.position.x - 400, camera.position.y - 300, camera);

      for (Cannon c : cannons) c.draw(batch);
      for (Master m : masters) m.draw(batch, font_16);
      for (Item i : itens) i.draw(batch);
      for (Message m : messages) m.draw(batch, font_16, player);
      player.draw(batch, font_16);
    }

    if (camera.position.x < 1290) {
      batch.setColor(new Color(1, 1, 1, 0.98f));
      batch.draw(tilemap.tiles[5], 768, 320, 64, 64);
      for (int i = 0; i < 3; i++) batch.draw(tilemap.tiles[30], 704 - 64 * i, 320, 64, 64);
      batch.setColor(Color.WHITE);
    }

    if (item_counter == 0) {
      batch.setColor(Color.BLACK);
      batch.draw(
          item_texture[0],
          camera.position.x - 360,
          camera.position.y + 180,
          96,
          96,
          0,
          0,
          32,
          32,
          false,
          false);
      batch.draw(
          item_texture[0],
          camera.position.x - 310,
          camera.position.y + 180,
          96,
          96,
          0,
          0,
          32,
          32,
          false,
          false);
      batch.setColor(Color.WHITE);
    } else if (item_counter == 1) {
      batch.setColor(new Color(1, 1, 1, item_alpha));
      batch.draw(
          item_texture[0],
          camera.position.x - 360,
          camera.position.y + 180,
          96,
          96,
          0,
          0,
          32,
          32,
          false,
          false);
      batch.setColor(Color.BLACK);
      batch.draw(
          item_texture[0],
          camera.position.x - 310,
          camera.position.y + 180,
          96,
          96,
          0,
          0,
          32,
          32,
          false,
          false);
      batch.setColor(Color.WHITE);
    } else {
      batch.draw(
          item_texture[0],
          camera.position.x - 360,
          camera.position.y + 180,
          96,
          96,
          0,
          0,
          32,
          32,
          false,
          false);
      batch.setColor(new Color(1, 1, 1, item_alpha));
      batch.draw(
          item_texture[0],
          camera.position.x - 310,
          camera.position.y + 180,
          96,
          96,
          0,
          0,
          32,
          32,
          false,
          false);
      batch.setColor(Color.WHITE);
    }

    font_32.draw(batch, "" + timer / 1000, camera.position.x + 300, camera.position.y + 270);

    if (stage_transition_alpha > 0) {
      batch.setColor(new Color(0, 0, 0, stage_transition_alpha));
      batch.draw(tilemap.tiles[0], camera.position.x - 450, camera.position.y - 350, 1200, 700);
      batch.setColor(Color.WHITE);
    }

    drawMenu();

    batch.end();
  }
Exemplo n.º 2
0
  private void update(float delta) {
    if (combo.update(gamepad)) {
      player.edu();
      DataManager dm = new DataManager();
      if (dm.markAchievement("edu", player)) player.showAchievement("Edu Mode on");
    }
    Gdx.graphics.setTitle("Ninja Time Fps: " + Gdx.graphics.getFramesPerSecond());
    tilemap.update(camera, player, delta, player.master_volume);

    vwidth = Gdx.graphics.getWidth();
    vheight = Gdx.graphics.getHeight();
    float wscale = vwidth / 800f;
    float hscale = vheight / 600f;

    if (item_counter != player.item_counter) {
      item_counter = player.item_counter;
      item_alpha = 0;
    }
    if (item_counter != 0 && item_alpha < 1) {
      item_alpha += delta * 0.5f;
    }

    if (Gdx.input.isKeyJustPressed(Input.Keys.F1)) tilemap.edit_mode = !tilemap.edit_mode;

    if (tilemap.edit_mode) {
      options = false;
      volume = false;
    } else if (!next_stage) {
      if (gamepad == null) updateMenuKeyboard(delta);
      else updateMenuGamepad(delta);
    }
    if (options || volume) start_time = System.currentTimeMillis();
    if (!options && !volume) {
      timer += System.currentTimeMillis() - start_time;
      start_time = System.currentTimeMillis();
      if (can_control) player.update(delta, tilemap.map, tilemap.width, tilemap.height);
      for (Cannon c : cannons) c.update(delta, camera, player, player.master_volume);
      for (Master m : masters) m.update(delta, camera, player);
      for (Item i : itens) i.update(player, delta, player.master_volume);
      for (Message m : messages) m.update(delta, player);

      if (!tilemap.edit_mode) {
        float x = 0;
        float y = 0;

        if (player.position[1] > camera.position.y + 50
            && camera.position.y - 300 < tilemap.height - 608)
          y += player.position[1] - camera.position.y - 50;
        else if (player.position[1] < camera.position.y - 150 && camera.position.y - 300 > 8)
          y += player.position[1] - camera.position.y + 150;
        if (player.position[0] > camera.position.x + 40
            && camera.position.x - 400 < tilemap.width - 808)
          x += player.position[0] - camera.position.x - 40;
        else if (player.position[0] < camera.position.x - 100 && camera.position.x - 400 > 8)
          x += player.position[0] - camera.position.x + 100;

        if (camera.position.x + x > tilemap.width - 408)
          x += tilemap.width - 408 - camera.position.x - x;
        else if (camera.position.x + x < 408) x += 408 - camera.position.x - x;
        if (camera.position.y + y > tilemap.height - 308)
          y += tilemap.height - 308 - camera.position.y - y;
        else if (camera.position.y + y < 308) y += 308 - camera.position.y - y;

        camera.translate(x, y);
        if (x != 0 || y != 0) camera.update();
      } else {
        if (Gdx.input.isKeyJustPressed(Input.Keys.BACKSPACE)) {
          player.position[0] =
              (Gdx.input.getX() + camera.position.x * wscale - vwidth / 2) / wscale;
          player.position[1] =
              ((vheight - Gdx.input.getY()) + camera.position.y * hscale - vheight / 2) / hscale;
        }
      }

      if (player.interact_press && !next_stage && player.rect().overlaps(next_stage_door)) {
        can_control = false;
        next_stage = true;
      }

      if (next_stage) {
        stage_transition_alpha += delta * 0.75f;
        transition_angle -= 0.2f * delta;
        if (camera.zoom > 0.04) camera.zoom += transition_angle * 0.05f;
        camera.rotate(transition_angle * 0.75f);
        camera.update();
        main_theme.setVolume((1 - stage_transition_alpha) * player.master_volume);
        if (camera.zoom < 0) camera.zoom = 0.01f;
        if (stage_transition_alpha > 1) {
          stage_transition_alpha = 1;
          main_theme.stop();
          game.setScreen(
              new Points_state(
                  game,
                  player,
                  player.master_volume,
                  master_texture,
                  item_texture,
                  cannonD,
                  cannonR,
                  cannonL,
                  cannonBall,
                  ninja_star,
                  font_32,
                  font_16,
                  main_theme,
                  bomb_sound,
                  item_sound,
                  player.death_counter,
                  4,
                  item_counter,
                  num_itens,
                  timer,
                  50000,
                  true,
                  3,
                  "It's a me, a master!"));
          minorDipose();
          changed_screen = true;
          return;
        }
      } else if (stage_transition_alpha > 0) {
        stage_transition_alpha -= delta * 0.5f;
        if (stage_transition_alpha < 0) stage_transition_alpha = 0;
        main_theme.setVolume((1 - stage_transition_alpha) * player.master_volume);
      } else if (player.clock_playing != -1) {
        main_theme.setVolume(player.master_volume * 0.2f);
      } else main_theme.setVolume(player.master_volume);
    }
  }