Exemplo n.º 1
0
  private void drawCullingRectangles(ShapeRenderer shapeRenderer, Color color) {
    for (BoundingBox br : boundingBoxes) {

      Rectangle r = br.rectangle;
      Rectangle cullingArea = getCullingArea(tmpRectangle, r, angleRad, position, scale);

      shapeRenderer.set(ShapeRenderer.ShapeType.Filled);

      Color fillColor = tmpColor.set(color);
      fillColor.a *= 0.25f;

      shapeRenderer.setColor(fillColor);

      shapeRenderer.rect(cullingArea.x, cullingArea.y, cullingArea.width, cullingArea.height);

      tmp.set(r.x, r.y).rotateRad(angleRad).add(position);
      tmp1.set(r.x + r.width, r.y).rotateRad(angleRad).add(position);
      tmp2.set(r.x + r.width, r.y + r.height).rotateRad(angleRad).add(position);
      tmp3.set(r.x, r.y + r.height).rotateRad(angleRad).add(position);

      shapeRenderer.set(ShapeRenderer.ShapeType.Line);
      shapeRenderer.setColor(color);

      shapeRenderer.line(tmp, tmp1);
      shapeRenderer.line(tmp1, tmp2);
      shapeRenderer.line(tmp2, tmp3);
      shapeRenderer.line(tmp3, tmp);
    }
  }
Exemplo n.º 2
0
  /** Renders a blue rectangle showing the field of view of the closeup camera */
  public void render(ShapeRenderer renderer) {
    if (!inCloseupMode) {
      // Figure out the location of the camera corners in the world
      Vector2 bottomLeft = myUnproject(closeupCamera, 0, closeupCamera.viewportHeight);
      Vector2 bottomRight =
          myUnproject(closeupCamera, closeupCamera.viewportWidth, closeupCamera.viewportHeight);
      Vector2 topRight = myUnproject(closeupCamera, closeupCamera.viewportWidth, 0);
      Vector2 topLeft = myUnproject(closeupCamera, 0, 0);

      // Draw a rectangle showing the closeup camera's field of view
      renderer.begin(ShapeType.Line);
      renderer.setColor(Color.BLUE);
      float[] poly = {
        bottomLeft.x,
        bottomLeft.y,
        bottomRight.x,
        bottomRight.y,
        topRight.x,
        topRight.y,
        topLeft.x,
        topLeft.y
      };
      renderer.set(ShapeType.Line);
      renderer.polygon(poly);
      renderer.end();
    }
  }
Exemplo n.º 3
0
 public static void drawPoint(Vector2 point, View view, Color color) {
   ShapeRenderer shapeRenderer = view.getShapeRenderer();
   shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
   shapeRenderer.setColor(color);
   float w, h;
   w = h = 5 * view.getCamera().zoom;
   shapeRenderer.rect(point.x - w / 2, point.y - h / 2, w, h);
 }
Exemplo n.º 4
0
  @Override
  public void render(SpriteBatch sb) {
    float leftEdge = player.getPosition().x - cam.viewportWidth / 2 + player.xOffset;
    sb.setProjectionMatrix(cam.combined);
    sb.begin();
    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);
    sb.draw(
        background,
        player.getPosition().x - cam.viewportWidth / 2 + player.xOffset,
        0,
        cam.viewportWidth,
        cam.viewportHeight);
    sb.end();

    Gdx.gl.glEnable(GL20.GL_BLEND);

    sr.setProjectionMatrix(cam.combined);
    sr.begin(ShapeRenderer.ShapeType.Filled);
    // Draw sparkles
    for (int i = 0; i < NUM_SHIMMERS; i++) {
      sr.setColor(
          whiteValue,
          whiteValue,
          whiteValue,
          Math.abs((float) Math.sin(Math.PI * shimmers.get(i).life / Shimmer.MAX_LIFE)));
      sr.circle(
          shimmers.get(i).x + player.getPosition().x - cam.viewportWidth / 2 + player.xOffset,
          shimmers.get(i).y,
          (float) Math.abs(Math.sin(Math.PI * shimmers.get(i).life / Shimmer.MAX_LIFE))
              * shimmers.get(i).size);
    }
    sr.end();
    sb.begin();
    // Draw pause
    sb.draw(
        pauseButton,
        cam.position.x - cam.viewportWidth / 2 + cam.viewportWidth * .05f,
        cam.viewportHeight * .95f - pauseButton.getHeight());

    // Draw balloon
    sb.draw(
        balloon,
        cam.position.x
            - cam.viewportWidth / 2
            + balloonFluctuation.getPosition().x
            - balloon.getWidth() / 2,
        balloonFluctuation.getPosition().y - balloon.getHeight() / 2);

    // Draw text
    if (!textBox.finished) {
      sb.end();
      Gdx.gl.glEnable(GL20.GL_BLEND);
      sr.setProjectionMatrix(cam.combined);
      sr.setAutoShapeType(true);
      sr.begin();
      sr.set(ShapeRenderer.ShapeType.Filled);
      sr.setColor(1f, 1f, 1f, (textBox.alpha > .4f) ? .4f : textBox.alpha);
      // Vert
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2 - textBox.padding / 2,
          textBox.y - textBox.height / 2,
          textBox.width + textBox.padding,
          textBox.height);
      // Horiz
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2,
          textBox.y + textBox.height / 2,
          textBox.width,
          textBox.padding / 2);
      sr.rect(
          leftEdge + textBox.x - textBox.width / 2,
          textBox.y - textBox.height / 2,
          textBox.width,
          -textBox.padding / 2);
      sr.end();
      sb.begin();
      if (textBox.boxOpened) {
        font.setColor(1f, 1f, 1f, textBox.alpha);
        // First line
        font.draw(
            sb,
            textBox.firstLineBuffer,
            (leftEdge + textBox.x - (textBox.width / 2)),
            textBox.y + textBox.height / 2);
        // Second line
        font.draw(
            sb,
            textBox.secondLineBuffer,
            (leftEdge + textBox.x - (textBox.width / 2)),
            textBox.y
                + textBox.height / 2
                - font.getBounds(sceneText.get(textCount).get(0)).height * 1.5f);
      }
    }

    // clouds
    sb.setColor(whiteValue, whiteValue, whiteValue, .75f);
    sb.draw(cloud, clouds.get(0).getPosition().x, clouds.get(0).getPosition().y);
    sb.draw(cloud, clouds.get(1).getPosition().x, clouds.get(1).getPosition().y);

    // draw note
    sb.setColor(whiteValue, whiteValue * (230f / 255f), whiteValue, 1f);
    sb.draw(
        noteAnim.getFrame(),
        note.getPosition().x,
        note.getPosition().y,
        noteAnim.getFrame().getRegionWidth() / 2,
        noteAnim.getFrame().getRegionHeight() / 2,
        noteAnim.getFrame().getRegionWidth(),
        noteAnim.getFrame().getRegionHeight(),
        noteScale,
        noteScale,
        noteRotation);

    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);
    // Draw player
    sb.draw(
        planeRegion,
        player.getPosition().x,
        player.getPosition().y,
        planeRegion.getRegionWidth() / 2,
        planeRegion.getRegionHeight() / 2,
        player.getPlane().getWidth() * .75f,
        player.getPlane().getHeight() * .75f,
        1,
        1,
        player.rotation);

    sb.setColor(whiteValue, whiteValue, whiteValue, 1f);

    // draw brush
    for (FluctuatingObject f : brushmoving) {
      sb.draw(brush, f.getPosition().x, f.getPosition().y);
    }

    sb.end();
    // HUD
    Matrix4 uiMatrix = cam.combined.cpy();
    uiMatrix.setToOrtho2D(0, 0, OwlCityTribute.WIDTH, OwlCityTribute.HEIGHT);

    sb.setProjectionMatrix(uiMatrix);
    sb.begin();
    sb.draw(vignette, 0, 0, cam.viewportWidth, cam.viewportHeight);
    sb.end();
    sr.begin(ShapeRenderer.ShapeType.Filled);
    Gdx.gl.glEnable(GL20.GL_BLEND);

    sr.setColor(1f, 1f, 1f, whiteOverlay);
    sr.setProjectionMatrix(cam.combined);
    sr.rect(leftEdge, 0, cam.viewportWidth, cam.viewportHeight);
    sr.end();
  }