public void update(float delta) {
    Entity playerEntity = player.get(0);

    PlayerSteerableComponent psc = cmpsc.get(playerEntity);

    for (int i = 0; i < entities.size(); i++) {
      Entity entity = entities.get(i);

      TalkComponent tc = cmtc.get(entity);
      NonControllablePersonSteerableComponent ncpstc = cmstc.get(entity);
      if (ncpstc.x - 160 < psc.getPosition().x
          && psc.getPosition().x < ncpstc.x + 160
          && ncpstc.y - 210 < psc.getPosition().y
          && psc.getPosition().y < ncpstc.y + 210) {
        layout.setText(font, tc.textToSay);
        float x = ncpstc.x - (layout.width / 2);
        float y = ncpstc.y + layout.height + 15;
        batch.end();
        shapeRenderer.setProjectionMatrix(TwoD.getMain().camera.combined);
        shapeRenderer.begin(ShapeType.Filled);
        shapeRenderer.setColor(Color.WHITE);
        shapeRenderer.rect(x - 13, y + 2, 26 + layout.width, 26 + layout.height);
        shapeRenderer.setColor(Color.BLACK);
        shapeRenderer.rect(x - 10, y + 5, 20 + layout.width, 20 + layout.height);
        shapeRenderer.end();
        batch.begin();
        font.draw(batch, layout, x, y + 25);
      }
    }
  }
示例#2
0
  private void renderNeighbourCollisionAreas(ShapeRenderer sr) {
    float minorX = player.pos.x - player.width / 2f;
    float majorX = player.pos.x + player.width / 2f;

    float minorY = player.pos.y - player.height / 2f;
    float majorY = player.pos.y + player.height / 2f;

    sr.setColor(Color.NAVY);
    sr.rect(MathUtils.round(minorX), player.pos.y, 1f, 1f);
    sr.rect(MathUtils.round(majorX), player.pos.y, 1f, 1f);
    sr.rect(player.pos.x, MathUtils.round(minorY), 1f, 1f);
    sr.rect(player.pos.x, MathUtils.round(majorY), 1f, 1f);
  }
示例#3
0
  private void renderShrine(ShapeRenderer shapes, SpriteBatch batch) {
    batch.end();

    // 2. clear our depth buffer with 1.0
    Gdx.gl.glClearDepthf(1f);
    Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT);

    // 3. set the function to LESS
    Gdx.gl.glDepthFunc(GL20.GL_LESS);

    // 4. enable depth writing
    Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

    // 5. Enable depth writing, disable RGBA color writing
    Gdx.gl.glDepthMask(true);
    Gdx.gl.glColorMask(false, false, false, false);

    // 6. render your primitive shapes
    shapes.begin(ShapeType.Filled);

    // TODO: remove setColor if not needed.
    shapes.setColor(1f, 0f, 0f, 0.5f);
    // shapes.circle(200, 200, 100);
    shapes.setColor(0f, 1f, 0f, 0.5f);
    // shapes.rect(200, 200, 100, 100);
    shapes.rect(-300, 0, 600, 500);

    shapes.rect(100, 100, 100, 100);

    shapes.end();

    batch.begin();
    // 8. Enable RGBA color writing
    //   (SpriteBatch.begin() will disable depth mask)
    Gdx.gl.glColorMask(true, true, true, true);

    // 9. Make sure testing is enabled.
    Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

    // 10. Now depth discards pixels outside our masked shapes
    Gdx.gl.glDepthFunc(GL20.GL_EQUAL);

    shrineOff.render(batch);
    shrineOn.setAlpha(shrineGlowAlpha);
    shrineOn.render(batch);

    batch.end();
    Gdx.gl.glDepthFunc(GL20.GL_ALWAYS);
    batch.begin();
  }
示例#4
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);
    }
  }
示例#5
0
 public void drawDebug(ShapeRenderer shapeRenderer) {
   shapeRenderer.rect(
       collisionRectangle.x,
       collisionRectangle.y,
       collisionRectangle.width,
       collisionRectangle.height);
 }
示例#6
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();
  }
 private void drawProgress() {
   Gdx.gl.glClearColor(0, 0, 0, 1);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   renderer.setColor(Color.ORANGE);
   renderer.begin(ShapeType.Filled);
   renderer.rect(0, 0, 800, 600);
   renderer.end();
 }
示例#8
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);
 }
示例#9
0
 private void drawRectangles() {
   shapeRenderer.begin(ShapeType.Line);
   Player player = GameController.getInstance().getPlayer();
   float x = player.getX();
   float y = player.getY();
   shapeRenderer.setColor(Color.GREEN);
   shapeRenderer.rect(x, y, player.getWidth(), player.getHeight());
   shapeRenderer.end();
 }
示例#10
0
  public void render(SpriteBatch sb, ShapeRenderer sr, Point location) {
    Color color;
    if (!enabled) color = new Color(0.533f, 0.533f, 0.533f, 1f);
    else if (selected) color = new Color(0.533f, 0.533f, 0.8f, 1f);
    else color = new Color(0.133f, 0.133f, 0.8f, 1f);

    float border = 5f, height = 20f;

    Rectangle size = parent.getDefaultSize();

    sr.begin(ShapeType.Filled);

    // Draw track
    sr.setColor(Color.BLACK);
    sr.rect(location.x - 2.5f, location.y - 2.5f, size.width + 5, 25);
    sr.setColor(color);
    sr.rect(location.x, location.y, size.width, 20);

    // Draw slider
    float cx =
        location.x + size.width * Math.min(1f * step * val, maxVal - minVal) / (maxVal - minVal);
    float width_ptr = 20f, height_ptr = 30f;
    sr.setColor(Color.BLACK);
    sr.rect(
        cx - (border + width_ptr) / 2f,
        location.y - (height_ptr - height + border) / 2f,
        width_ptr + border,
        height_ptr + border);
    sr.setColor(0.133f, 0.133f, 0.8f, 1f);
    sr.rect(cx - width_ptr / 2f, location.y - (height_ptr - height) / 2f, width_ptr, height_ptr);
    sr.end();

    // Label
    String label = "" + Math.min(val * step + minVal, maxVal);
    BitmapFont font = Root.getFont(24);
    TextBounds lBound = font.getBounds(label);
    float width_t = lBound.width;

    sb.begin();
    if (!label.isEmpty()) {
      font.draw(sb, label, location.x - width_t - 20, location.y + height);
    }
    sb.end();
  }
 public void drawSelectedTile() {
   if (selectedTile.getX() != -1) {
     shapeRenderer.setColor(Color.RED);
     shapeRenderer.rect(
         selectedTile.getX() * Game.BLOCK_WIDTH,
         selectedTile.getY() * Game.BLOCK_HEIGHT,
         Game.BLOCK_WIDTH + Game.TILE_OFFSET,
         Game.BLOCK_HEIGHT + Game.TILE_OFFSET);
   }
 }
示例#12
0
 /**
  * Draws a filled rectangle using a <code>ShapeRenderer</code>.<br>
  * IMPORTANT: Don't forget to set the <code>ShapeRenderer</code>'s projection matrix with {@link
  * #setShapeRendererProjectionMatrix(Matrix4)}!
  *
  * @param batch - Since drawing is done with a <code>ShapeRenderer</code>, the active batch should
  *     be passed to this method to end/start it.
  */
 public static void fillRect(SpriteBatch batch, float x, float y, float w, float h, Color c) {
   batch.end();
   Gdx.gl.glEnable(GL20.GL_BLEND);
   shapes_.begin(ShapeType.Filled);
   shapes_.setColor(c);
   shapes_.rect(x, y, w, h);
   shapes_.end();
   Gdx.gl.glDisable(GL20.GL_BLEND);
   batch.begin();
 }
示例#13
0
 public static void renderHitboxs(World world, Camera camera) {
   shapeRenderer.setProjectionMatrix(camera.combined);
   shapeRenderer.begin(ShapeType.Line);
   for (GameObject entity : world.getEntities()) {
     if (entity.hitbox != null) {
       shapeRenderer.setColor(0, 1, 1, 1);
       shapeRenderer.rect(
           entity.hitbox.x, entity.hitbox.y, entity.hitbox.width, entity.hitbox.height);
     }
   }
   shapeRenderer.end();
 }
示例#14
0
  private void drawDebug() {
    debugRenderer.setProjectionMatrix(cam.combined);
    debugRenderer.begin(ShapeType.Line);
    for (Block block : world.getBlocks((int) CAMERA_WIDTH, (int) CAMERA_HEIGHT)) {
      Rectangle rect = block.getBounds();
      debugRenderer.setColor(new Color(1, 0, 0, 1));
      debugRenderer.rect(rect.x, rect.y, rect.width, rect.height);
    }

    for (Entity e : world.getEntities()) {
      Rectangle rect = e.getBounds();
      debugRenderer.setColor(new Color(0, 1, 1, 1));
      debugRenderer.rect(rect.x, rect.y, rect.width, rect.height);
    }

    Digger jaxon = world.getJaxon();
    Rectangle rect = jaxon.getBounds();
    debugRenderer.setColor(new Color(0, 1, 0, 1));
    debugRenderer.rect(rect.x, rect.y, rect.width, rect.height);
    debugRenderer.end();
  }
  public void render(float delta) {
    shape.setColor(shapeRed * color, shapeGreen * color, shapeBlue * color, 1);
    shape.begin(ShapeType.Filled);
    shape.rect(shapeX, shapeY, shapeWidth, shapeHeight);
    shape.end();
    shape.setColor(0, 0, 0, 1);
    shape.begin(ShapeType.Line);
    shape.rect(shapeX, shapeY, shapeWidth, shapeHeight);
    shape.end();

    if (shapeX > Gdx.graphics.getWidth()) {
      if (!touched) {
        score.setSpeed(tempSpeed / 100);
        score.setHeight(shapeHeight);
        score.setWidth(shapeWidth);
        score.setState(false);
        lifeCount.setLifeCount(lifeCount.getLifeCount() - 1);
      }

      reset();
    } else {
      shapeX += tempSpeed * delta;

      if (beingTouched()) {
        score.setSpeed(tempSpeed / 100);
        score.setHeight(shapeHeight);
        score.setWidth(shapeWidth);
        score.setState(true);
        color = 1;
        touched = true;
      }
    }

    if (color > 0) {
      color -= 0.005;
    } else {
      color = 0;
    }
  }
示例#16
0
  protected void process(Entity e) {
    if (pm.has(e)) {
      Position position = pm.getSafe(e);
      Gdx.gl.glEnable(GL10.GL_BLEND);
      Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
      //			Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
      if (cm.has(e)) {
        Circle circle = cm.getSafe(e);

        if (circle.filled) {
          shapeRenderer.begin(ShapeType.Filled);
        } else {
          shapeRenderer.begin(ShapeType.Line);
        }

        if (circle.borderSize > 0) {
          shapeRenderer.setColor(circle.borderColor);

          shapeRenderer.circle(position.x, position.y, circle.radius, circle.segments);
          shapeRenderer.setColor(circle.color);

          shapeRenderer.circle(
              position.x, position.y, circle.radius - circle.borderSize, circle.segments);

        } else {
          shapeRenderer.setColor(circle.color);

          shapeRenderer.circle(position.x, position.y, circle.radius, circle.segments);
        }

        shapeRenderer.end();
      }
      if (rm.has(e)) {

        Rectangle rectangle = rm.getSafe(e);

        shapeRenderer.setColor(rectangle.color);

        if (rectangle.filled) {
          shapeRenderer.begin(ShapeType.Filled);
        } else {
          shapeRenderer.begin(ShapeType.Line);
        }
        shapeRenderer.rect(position.x, position.y, rectangle.width, rectangle.height);

        shapeRenderer.end();
      }
      Gdx.gl.glDisable(GL10.GL_BLEND);
      Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
    }
  }
示例#17
0
文件: Nemici.java 项目: ninjo86/Prova
  public void update(float runtime) {
    x -= 1 / 10f;
    rectNemici.set(x, y, 35, 35);

    batch.begin();
    batch.draw(nemiciAnimation.getKeyFrame(runtime, true), x, y);
    // batch.draw(nemiciAnimation.getKeyFrame(runtime, true), 400, 300);
    batch.end();

    shapeRenderer.begin(ShapeType.Filled);
    shapeRenderer.setColor(55 / 255.0f, 80 / 255.0f, 100 / 255.0f, 1);
    shapeRenderer.rect(x, y, 35, 35);
    shapeRenderer.end();
  }
示例#18
0
  private void drawWeapon() {
    shapeRenderer.begin(ShapeType.Line);

    Player player = GameController.getInstance().getPlayer();

    float offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_RIGHT;
    float offsetY = Constants.WEAPON_OFFSET_FROM_PLAYER_Y;

    if (player.getFacing() == 0) {
      offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_RIGHT;
    } else {
      offsetX = Constants.WEAPON_OFFSET_FROM_PLAYER_X_FACING_LEFT;
    }

    Player p = player;

    Float deltaX = 0f;
    Float deltaY = 0f;

    Float playerXCentered = p.getX() + (p.getWidth() / 2);
    Float playerYCentered = p.getY() + (p.getHeight() / 2);

    Float mouseX = p.getTargetX();
    Float mouseY = p.getTargetY();

    deltaX = (mouseX - playerXCentered);
    deltaY = (mouseY - playerYCentered);

    Double angle = Math.atan2(deltaY.doubleValue(), deltaX.doubleValue());

    Double rotation = (Math.toDegrees(angle));

    float x = player.getX() + offsetX;
    float y = player.getY() + offsetY;
    shapeRenderer.setColor(Color.ORANGE);
    shapeRenderer.rect(
        x,
        y,
        Constants.WEAPON_ORIGIN_X,
        Constants.WEAPON_ORIGIN_Y,
        Constants.WEAPON_WIDTH,
        Constants.WEAPON_HEIGHT,
        1,
        player.getFacing() == 0 ? 1 : -1,
        rotation.intValue());
    shapeRenderer.setColor(Color.BLACK);
    shapeRenderer.circle(x + Constants.WEAPON_ORIGIN_X, y + Constants.WEAPON_ORIGIN_Y, 2);
    shapeRenderer.end();
  }
示例#19
0
  private void renderBox(Body body, float halfWidth, float halfHeight) {
    // get the bodies center and angle in world coordinates
    Vector2 pos = body.getWorldCenter();
    float angle = body.getAngle();

    // set the translation and rotation matrix
    transform.setToTranslation(pos.x, pos.y, 0);
    transform.rotate(0, 0, 1, (float) Math.toDegrees(angle));

    // render the box
    renderer.begin(ShapeType.Line);
    renderer.setTransformMatrix(transform);
    renderer.setColor(1, 1, 1, 1);
    renderer.rect(-halfWidth, -halfHeight, halfWidth * 2, halfHeight * 2);
    renderer.end();
  }
 @Override
 public void render(float delta) {
   Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   cam.update();
   shapeRenderer.setProjectionMatrix(cam.combined);
   shapeRenderer.setAutoShapeType(true);
   shapeRenderer.begin();
   shapeRenderer.setColor(0.8f, 0, 0, 1);
   shapeRenderer.rect(
       mcFlyCar[Rect.x.ordinal()],
       mcFlyCar[Rect.y.ordinal()],
       mcFlyCar[Rect.width.ordinal()],
       mcFlyCar[Rect.height.ordinal()]);
   shapeRenderer.end();
 }
示例#21
0
  public void drawDebug(SpriteBatch batch) {
    batch.end();

    ShapeRenderer renderer = DebugRendererManager.instance.debugRenderer;

    renderer.setProjectionMatrix(batch.getProjectionMatrix());
    renderer.setTransformMatrix(batch.getTransformMatrix());
    renderer.translate(getX(), getY(), 0);

    renderer.begin(ShapeRenderer.ShapeType.Line);
    renderer.setColor(new Color(Color.RED));
    renderer.rect(0, 0, getWidth(), getHeight());
    renderer.end();

    batch.begin();
  }
示例#22
0
  @Override
  public void render(SpriteBatch batch) {
    batch.end();
    mapRenderer.setView(camera);
    mapRenderer.render();
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    shapeRenderer.setColor(Color.BLUE);
    for (Rectangle rect : collisions) {
      shapeRenderer.rect(rect.x, rect.y, rect.getWidth(), rect.getHeight());
    }

    shapeRenderer.end();
    batch.begin();
    drawDebugInformation(batch);
    for (Entity entity : entities) {
      entity.render(batch);
    }
  }
示例#23
0
 @Override
 public void render(ShapeRenderer renderer, Transform transform) {
   tmp.set(renderer.getColor());
   renderer.setColor(color);
   // TODO rotation?
   float x = ox + (centre ? -width / 2f : 0);
   float y = oy + (centre ? -height / 2f : 0);
   renderer.rect(
       transform.x + x,
       transform.y + y,
       x + originX,
       y + originY,
       width,
       height,
       1,
       1,
       transform.rotation);
   renderer.setColor(tmp);
 }
  public static void draw(ShapeRenderer shaperenderer) {
    shaperenderer.setColor(Color.RED);
    shaperenderer.begin(ShapeRenderer.ShapeType.Line);
    shaperenderer.rect(SpriteHome.getPosition().x + 24, SpriteHome.getPosition().y + 130, 64, 60);
    shaperenderer.circle(
        Ball.getPosition().x + Ball.getSize().x / 2,
        Ball.getPosition().y + Ball.getSize().x / 2,
        Ball.getSize().x / 2);

    shaperenderer.circle(
        SpriteHome.getPosition().x + 16.8f + (128.8f / 2),
        SpriteHome.getPosition().y + 0 + (128.8f / 2),
        128.8f / 2);
    shaperenderer.circle(
        SpriteHome.getPosition().x + 16.8f + (128.8f / 2),
        SpriteHome.getPosition().y + (161 - 128.8f) + (128.8f / 2),
        128.8f / 2);
    shaperenderer.end();
  }
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    stateTime += Gdx.graphics.getDeltaTime();
    drawable.setRegion(character.getAnimation().getKeyFrame(stateTime));

    super.draw(batch, parentAlpha);

    if (selected) {
      batch.end();
      ShapeRenderer shape = new ShapeRenderer();
      shape.setProjectionMatrix(batch.getProjectionMatrix());
      shape.begin(ShapeType.Line);
      shape.setColor(Color.YELLOW);
      shape.rect(
          getX() + getParent().getParent().getX(),
          getY() + getParent().getParent().getY(),
          getPrefWidth(),
          getPrefHeight());
      shape.end();
      batch.begin();
    }
  }
示例#26
0
  public void render(Treasure cost) {
    fontScale = font.getScaleX();
    font.setScale(Math.max(Math.round(fontScale * scale), 1));
    if (!cost.equals(this.cost) || !this.equals(bounds)) {
      this.bounds = new Rectangle(this);
      this.cost = new Treasure(cost);

      caches = new ArrayList<costValueCache>();
      if (showCost) {
        if (cost.getGold() > 0) {
          caches.add(new costValueCache(Color.WHITE, "Cost: "));
          caches.add(new costValueCache(Color.YELLOW, cost.getGold() + " "));
        }
      }
      for (Element element : Element.values()) {
        int element1 = cost.getElement(element);
        if (element1 > 0) {
          caches.add(new costValueCache(Color.WHITE, element1 + "x "));
          caches.add(new costValueCache(element.getColor(), element.toString() + " "));
        }
      }

      render();

    } else {
      render();
    }

    font.setScale(fontScale);

    if (App.DEBUG != null) {
      shapeRenderer.setColor(Color.RED);
      shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
      shapeRenderer.rect(x, y, width, height);
      shapeRenderer.end();
    }
  }
示例#27
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();
  }
示例#28
0
 public void drawDebug(ShapeRenderer shape) {
   if (isHorizontal) shape.setColor(Color.RED);
   else shape.setColor(Color.CYAN);
   shape.rect(enemyRec.x, enemyRec.y, enemyRec.width, enemyRec.height);
   if (!isTarget) {
     if (game.player.isFlashLight()) {
       if (!isLeft)
         shape.line(
             enemyRec.x - normalRange / 2,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x + enemyRec.width + normalRange * 1.5f,
             enemyRec.getY() + enemyRec.getHeight() / 2);
       else
         shape.line(
             enemyRec.x + enemyRec.width + normalRange / 2,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x - normalRange * 1.5f,
             enemyRec.getY() + enemyRec.getHeight() / 2);
     } else {
       if (!isLeft)
         shape.line(
             enemyRec.x + enemyRec.width,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x + enemyRec.width + normalRange,
             enemyRec.getY() + enemyRec.getHeight() / 2);
       else
         shape.line(
             enemyRec.x,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x - normalRange,
             enemyRec.getY() + enemyRec.getHeight() / 2);
     }
   } else {
     if (game.player.isFlashLight()) {
       if (!isPlayerLeft)
         shape.line(
             enemyRec.x + enemyRec.width,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x + enemyRec.width + targetRange * 1.2f,
             enemyRec.getY() + enemyRec.getHeight() / 2);
       else
         shape.line(
             enemyRec.x,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x - targetRange * 1.2f,
             enemyRec.getY() + enemyRec.getHeight() / 2);
     } else {
       if (!isPlayerLeft)
         shape.line(
             enemyRec.x + enemyRec.width,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x + enemyRec.width + targetRange,
             enemyRec.getY() + enemyRec.getHeight() / 2);
       else
         shape.line(
             enemyRec.x,
             enemyRec.getY() + enemyRec.getHeight() / 2,
             enemyRec.x - targetRange,
             enemyRec.getY() + enemyRec.getHeight() / 2);
     }
   }
 }
示例#29
0
  @Override
  public void draw(Batch batch, float parentAlpha) {
    batch.draw(
        reorganize.get(),
        parent.getX() + reorganizePos.x,
        parent.getY() + reorganizePos.y,
        reorganizePos.width,
        reorganizePos.height);
    batch.draw(
        newMilitary.get(),
        parent.getX() + newMilitaryPos.x,
        parent.getY() + newMilitaryPos.y,
        newMilitaryPos.width,
        newMilitaryPos.height);
    batch.draw(
        recruit.get(),
        parent.getX() + recruitPos.x,
        parent.getY() + recruitPos.y,
        recruitPos.width,
        recruitPos.height);
    batch.draw(
        training.get(),
        parent.getX() + trainingPos.x,
        parent.getY() + trainingPos.y,
        trainingPos.width,
        trainingPos.height);
    batch.draw(
        merge.get(),
        parent.getX() + mergePos.x,
        parent.getY() + mergePos.y,
        mergePos.width,
        mergePos.height);
    batch.draw(
        disband.get(),
        parent.getX() + disbandPos.x,
        parent.getY() + disbandPos.y,
        disbandPos.width,
        disbandPos.height);
    batch.draw(
        upgrade.get(),
        parent.getX() + upgradePos.x,
        parent.getY() + upgradePos.y,
        upgradePos.width,
        upgradePos.height);

    for (TextWidget<ArchitectureCommandFrame.TextType> textWidget : textWidgets) {
      textWidget.setPosition(
          textWidget.getExtra().position.x + parent.getX(),
          textWidget.getExtra().position.y + parent.getY());
      if (textWidget.getExtra().staticText) {
        textWidget.setText(textWidget.getExtra().name);
      } else {
        textWidget.setText(
            parent.getCurrentArchitecture().getFieldString(textWidget.getExtra().name));
      }
      textWidget.draw(batch, parentAlpha);
    }

    if (militaryBottomPane == null) {
      initMilitaryBottomPane();
    }
    if (militaryTopPane == null) {
      initMilitaryTopPane();
    }

    if (currentMilitary != null) {
      batch.end();

      shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

      shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
      shapeRenderer.setTransformMatrix(batch.getTransformMatrix());

      shapeRenderer.setColor(selectedBorderColor);
      shapeRenderer.rect(
          parent.getX() + currentMilitaryPos.getX(),
          parent.getY() + currentMilitaryPos.getY(),
          currentMilitaryPos.getWidth(),
          currentMilitaryPos.getHeight());

      shapeRenderer.end();

      batch.begin();
    }
  }
示例#30
0
 private void renderPlayer(ShapeRenderer sr) {
   sr.setColor(Color.PURPLE);
   sr.rect(player.pos.x, player.pos.y, player.width, player.height);
 }