private void renderHP() {
    ShapeRenderer render = new ShapeRenderer();

    int hp = world.thePlayer.hp;

    if (hp >= 50) render.setColor(0.0f, 1.0f, 0.0f, 1);
    else if (hp > 33) render.setColor(1.0f, 1.0f, 0.0f, 1);
    else if (hp > 0) render.setColor(1.0f, 0.0f, 0.0f, 1);

    if (!(hp < 33)) {
      render.begin(ShapeRenderer.ShapeType.FilledRectangle);
      render.filledRect(5, 5, hp * 2, 20);
      render.end();
    }

    if (flickerDraw && (hp < 33)) {
      render.begin(ShapeRenderer.ShapeType.FilledRectangle);
      render.filledRect(5, 5, hp * 2, 20);
      render.end();
      flickerDraw = false;
    } else if (lastFlicker > 3) {
      flickerDraw = true;
      this.lastFlicker = 0;
    } else this.lastFlicker++;
  }
  @Override
  public void render() {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    spriteBatch.setProjectionMatrix(worldCamera.projection);
    spriteBatch.setTransformMatrix(worldCamera.view);
    spriteBatch.begin();
    farmSprite.draw(spriteBatch);
    spriteBatch.end();

    shapeRenderer.setProjectionMatrix(worldCamera.projection);
    shapeRenderer.setTransformMatrix(worldCamera.view);

    shapeRenderer.setColor(1f, 1f, 1f, 1f);
    shapeRenderer.begin(ShapeType.Line);
    for (int i = 0; i < convexHull2d.getPointsCount(); i++) {
      float x0 = convexHull2d.getX(i);
      float y0 = convexHull2d.getY(i);
      if (i + 1 == convexHull2d.getPointsCount()) {
        float x1 = convexHull2d.getX(0);
        float y1 = convexHull2d.getY(0);
        shapeRenderer.line(x0, y0, x1, y1);
        break;
      }
      float x1 = convexHull2d.getX(i + 1);
      float y1 = convexHull2d.getY(i + 1);
      shapeRenderer.line(x0, y0, x1, y1);
    }
    shapeRenderer.end();

    shapeRenderer.setColor(0f, 1f, 1f, 1f);
    shapeRenderer.begin(ShapeType.Line);
    for (int i = 0; i < smallConvexHull2d.getPointsCount(); i++) {
      float x0 = smallConvexHull2d.getX(i);
      float y0 = smallConvexHull2d.getY(i);
      if (i + 1 == smallConvexHull2d.getPointsCount()) {
        float x1 = smallConvexHull2d.getX(0);
        float y1 = smallConvexHull2d.getY(0);
        shapeRenderer.line(x0, y0, x1, y1);
        break;
      }
      float x1 = smallConvexHull2d.getX(i + 1);
      float y1 = smallConvexHull2d.getY(i + 1);
      shapeRenderer.line(x0, y0, x1, y1);
    }
    shapeRenderer.end();

    shapeRenderer.setColor(1f, 0f, 0f, 1f);
    shapeRenderer.begin(ShapeType.FilledCircle);
    for (int i = 0; i < convexHull2d.getPointsCount(); i++) {
      float x = convexHull2d.getX(i);
      float y = convexHull2d.getY(i);
      shapeRenderer.filledCircle(x, y, 1f, 5);
    }
    shapeRenderer.end();
  }
Beispiel #3
0
  public void render() {
    shapeRenderer.begin(ShapeType.FilledRectangle);
    shapeRenderer.setColor(color);
    shapeRenderer.filledRect(x, y, width, height);
    shapeRenderer.end();

    shapeRenderer.begin(ShapeType.FilledCircle);
    shapeRenderer.setColor(1.0f, 0.0f, 0.0f, 1.0f);
    shapeRenderer.filledCircle(x, y, 3);
    shapeRenderer.end();
  }
  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);
    }
  }
Beispiel #5
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();
    }
  }
Beispiel #6
0
  @Override
  public void render(float arg0) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    camera.update();
    if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
      if (focused) {
        focused = false;
      } else {
        goBack();
      }
    }

    if (focused) {
      shapeRenderer.begin(ShapeType.FilledRectangle);
      Color c = new Color(0.15f, 0.4f, 0.15f, 1f);
      shapeRenderer.setColor(c);
      shapeRenderer.filledRect(focusedBox.x, focusedBox.y, focusedBox.width, focusedBox.height);
      shapeRenderer.end();
    }

    batch.begin();
    ObjectMap.Entries<String, Rectangle> it = bindingButtons.entries();
    // draw back button text
    font.draw(batch, "Back", backButton.x, backButton.y + backButton.height);
    // draw option texts
    while (it.hasNext()) {
      ObjectMap.Entry<String, Rectangle> entry = it.next();
      Rectangle bounds = entry.value;
      font.draw(batch, entry.key, bounds.x, bounds.y + bounds.height);
      Binding binding = game.getBindings().get(entry.key);
      font.draw(batch, binding.character, bounds.x + 200.0f, bounds.y + bounds.height);
    }
    batch.end();
  }
  @Override
  public void render() {
    viewport.apply();

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    renderer.setProjectionMatrix(viewport.getCamera().combined);
    renderer.begin(ShapeType.Filled);

    // Since we're using an extend viewport, the world might be bigger than we expect
    float worldCenterX = viewport.getWorldWidth() / 2;
    float worldCenterY = viewport.getWorldHeight() / 2;

    // TODO: Figure out how long it's been since the animation started using TimeUtils.nanoTime()
    long delta = TimeUtils.nanoTime() - appCreationTime;

    // TODO: Use MathUtils.nanoToSec to figure out how many seconds the animation has been running
    float seconds = delta * MathUtils.nanoToSec;

    // TODO: Figure out how many cycles have elapsed since the animation started running
    float cycles = seconds / CYCLE;

    // TODO: Figure out where in the cycle we are
    float cyclePosition = cycles % 1;

    // TODO: Use MathUtils.sin() to set the x position of the circle

    float x = worldCenterX + MOVEMENT_DISTANCE * MathUtils.sin(MathUtils.PI2 * cyclePosition);
    float y = worldCenterY;
    renderer.circle(x, y, CIRCLE_RADIUS);
    renderer.end();
  }
  private void drawTrajectory() {
    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 originX = p.getX() + offsetX + Constants.WEAPON_ORIGIN_X;
    Float originY = p.getY() + offsetY + Constants.WEAPON_ORIGIN_Y;

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

    Float deltaX = (mouseX - originX);
    Float deltaY = (mouseY - originY);

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

    Float x = (float) Math.cos(angle.floatValue());
    Float y = (float) Math.sin(angle.floatValue());

    Float calculatedX = originX + x * Constants.SHOT_DISTANCE_FROM_ORIGIN;
    Float calculatedY = originY + y * Constants.SHOT_DISTANCE_FROM_ORIGIN;

    shapeRenderer.begin(ShapeType.Line);
    shapeRenderer.setColor(Color.RED);
    shapeRenderer.line(calculatedX, calculatedY, mouseX, mouseY);
    shapeRenderer.end();
  }
 public void render(SpriteBatch sb, ShapeRenderer sr) {
   double drawx = getDrawX();
   double drawy = getDrawY();
   if (drawx < -40 || drawx > Gdx.graphics.getWidth() + 40) return;
   if (drawy < -40 || drawy > Gdx.graphics.getHeight() + 40) return;
   Gdx.gl.glEnable(GL20.GL_BLEND);
   Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
   float red = Math.min(1f, 2f * (1f - health / maxHealth));
   float green = Math.min(1f, 2f * (health / maxHealth));
   sr.setColor(red * 0.75f, green * 0.75f, 0, 0.9f);
   draw(sb, sr, 20, ShapeType.Filled);
   sr.setColor(red, green, 0, 1f);
   draw(sb, sr, 20, ShapeType.Line);
   sr.begin(ShapeType.Filled);
   sr.circle((float) getDrawX(), (float) getDrawY(), 2);
   sr.end();
   Gdx.gl.glDisable(GL20.GL_BLEND);
   if (!arms.isEmpty() && arms.getFirst() != null) arms.getFirst().render(sb, sr);
   //		if(isAI) {
   //			float barWidth = 60;
   //			sr.begin(ShapeType.Filled);
   //			float red = Math.min(1f, 2f * (1f - health / maxHealth));
   //			float green = Math.min(1f, 2f * (health / maxHealth));
   //			sr.setColor(red, green, 0, 1f);
   //			sr.rect((float) getDrawX() - barWidth / 2, (float) getDrawY() + 30, (float) (barWidth *
   // health / maxHealth), 5);
   //			sr.end();
   //		}
 }
  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);
      }
    }
  }
 private void drawCircles(OrthographicCamera camera) {
   shapeRenderer.setProjectionMatrix(camera.projection);
   shapeRenderer.begin(ShapeType.Line);
   shapeRenderer.setColor(Color.ORANGE);
   shapeRenderer.circle(mouseX - 300f, Constants.CAMERA_HEIGHT - mouseY - 300f, 10);
   shapeRenderer.end();
   shapeRenderer.setProjectionMatrix(camera.combined);
 }
 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();
 }
Beispiel #13
0
 /** Draws the debug rects for the specified actor and any children, recursively. */
 public void draw(Actor actor) {
   if (disabled) return;
   shapes.setProjectionMatrix(stage.getCamera().projection);
   shapes.setTransformMatrix(stage.getCamera().view);
   shapes.begin(ShapeType.Line);
   drawRecursive(actor);
   shapes.end();
 }
 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();
 }
Beispiel #15
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();
 }
Beispiel #16
0
 /**
  * Draws an outline of a 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 drawLine(SpriteBatch batch, float x1, float y1, float x2, float y2, Color c) {
   batch.end();
   Gdx.gl.glEnable(GL20.GL_BLEND);
   shapes_.begin(ShapeType.Line);
   shapes_.setColor(c);
   shapes_.line(x1, y1, x2, y2);
   shapes_.end();
   Gdx.gl.glDisable(GL20.GL_BLEND);
   batch.begin();
 }
Beispiel #17
0
 @Override
 public void draw(SpriteBatch batch, float parentAlpha) {
   shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
   batch.end();
   shapeRenderer.begin(ShapeType.Circle);
   shapeRenderer.setColor(shapeFillColor);
   shapeRenderer.circle(getX(), getY(), 20);
   shapeRenderer.end();
   batch.begin();
 }
 public static void drawPoint2Point(Vector2 pos1, Vector2 pos2) {
   shapeRenderer.setProjectionMatrix(camera.combined);
   shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
   shapeRenderer.setColor(0, 0, 1, 1);
   shapeRenderer.circle(pos1.x, pos1.y, 5);
   shapeRenderer.circle(pos2.x, pos2.y, 5);
   //        shapeRenderer.line(pos1, pos2, 10);
   shapeRenderer.rectLine(pos1, pos2, 3);
   shapeRenderer.end();
 }
Beispiel #19
0
  @Override
  public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    renderer.begin(ShapeType.Filled);
    renderer.setColor(Color.WHITE);

    // The most basic circle you can draw, with the segment count set for you
    renderer.circle(100, 100, 90);
    renderer.setColor(Color.YELLOW);

    // We can also draw partial circle, or arc
    renderer.arc(300, 100, 90, 45, 270);
    //        renderer.circl
    // What happens when we set the segments count too low
    renderer.circle(500, 100, 90, 10);
    renderer.end();

    // Circles can be drawn in either Filled or Line mode!
    renderer.begin(ShapeType.Line);
    renderer.circle(100, 300, 90);
    //        renderer.setColor(Color.RED);
    //        renderer.arc(300, 100, 90, 90, 45);
    //        renderer.arc(300, 100, 90, -45, -10);
    //        renderer.setColor(Color.YELLOW);

    // Let's draw target rings
    for (int radius = 80; radius > 0; radius -= 10) {
      renderer.circle(100, 300, radius);
    }

    // We can also draw the outline of an arc
    renderer.arc(300, 300, 90, 0, 90);

    // Let's draw some a funky snail shell
    final int arcs = 20;
    for (int i = 1; i < arcs; i++) {
      renderer.arc(300, 300, (1 - 1.0f * i / arcs) * 90, 360.0f * i / arcs, 90);
    }
    renderer.end();
  }
 @Override
 public void render(float delta) {
   Gdx.gl.glEnable(GL10.GL_BLEND);
   if (null != snapPoint) {
     render.begin(ShapeType.FilledRectangle);
     render.setColor(Color.BLUE);
     render.filledRect(snapPoint.x - 5, snapPoint.y - 5, 2 * 5, 2 * 5);
     render.end();
   }
   Gdx.gl.glDisable(GL10.GL_BLEND);
 }
Beispiel #21
0
 public static void drawPolygon(ShapeRenderer sr, float[] polygon, float lineWidth) {
   ShapeRenderer.ShapeType type = sr.getCurrentType();
   sr.end();
   if (lineWidth == 0f) {
     sr.begin(ShapeRenderer.ShapeType.Line);
     sr.polygon(polygon);
   } else {
     sr.begin(ShapeRenderer.ShapeType.Filled);
     for (int i = 0; i < polygon.length / 2; i++) {
       sr.rectLine(
           polygon[i * 2],
           polygon[i * 2 + 1],
           polygon[(i * 2 + 2) % polygon.length],
           polygon[(i * 2 + 3) % polygon.length],
           lineWidth);
     }
   }
   sr.end();
   sr.begin(type);
 }
  private void render_game_background() {
    shapeCreator.begin(ShapeType.Line);
    shapeCreator.setProjectionMatrix(camera.combined);
    shapeCreator.setColor(Color.WHITE);
    // Top line of user's play grid
    shapeCreator.line(
        TOP_LEFT_USER_GRID_X,
        TOP_LEFT_USER_GRID_Y,
        (float) (TOP_LEFT_USER_GRID_X + (CONSTANT.GAME_WORLD_WIDTH * (3.0 / 5.0))),
        TOP_LEFT_USER_GRID_Y);

    // Bottom line of user's play grid
    shapeCreator.line(
        TOP_LEFT_USER_GRID_X,
        (float) (TOP_LEFT_USER_GRID_Y - (CONSTANT.GAME_WORLD_HEIGHT * (12.0 / 35.0))),
        (float) (TOP_LEFT_USER_GRID_X + (CONSTANT.GAME_WORLD_WIDTH * (3.0 / 5.0))),
        (float) (TOP_LEFT_USER_GRID_Y - (CONSTANT.GAME_WORLD_HEIGHT * (12.0 / 35.0))));

    // Center line of user's play grid
    shapeCreator.line(
        TOP_LEFT_USER_GRID_X,
        (float) (TOP_LEFT_USER_GRID_Y - (CONSTANT.GAME_WORLD_HEIGHT * (6.0 / 35.0))),
        (float) (TOP_LEFT_USER_GRID_X + (CONSTANT.GAME_WORLD_WIDTH * (3.0 / 5.0))),
        (float) (TOP_LEFT_USER_GRID_Y - (CONSTANT.GAME_WORLD_HEIGHT * (6.0 / 35.0))));

    // Left Border of user's play grid
    for (int counter = 0; counter < 8; counter++) {
      shapeCreator.line(
          (float) (TOP_LEFT_USER_GRID_X + (counter * CONSTANT.GAME_WORLD_WIDTH * (3.0 / 35.0))),
          TOP_LEFT_USER_GRID_Y,
          (float) (TOP_LEFT_USER_GRID_X + (counter * CONSTANT.GAME_WORLD_WIDTH * (3.0 / 35.0))),
          (float) (TOP_LEFT_USER_GRID_Y - (CONSTANT.GAME_WORLD_HEIGHT * (12.0 / 35.0))));

      if (counter < 7) {
        user_locations.add(
            new Vector2(
                (float)
                    (TOP_LEFT_USER_GRID_X
                        + (CONSTANT.GAME_WORLD_WIDTH * (1.5 / 35.0))
                        + (counter * CONSTANT.GAME_WORLD_WIDTH * (3.0 / 35.0))),
                (float) (TOP_LEFT_USER_GRID_Y + (CONSTANT.GAME_WORLD_HEIGHT * (3.0 / 35.0)))));

        user_locations.add(
            new Vector2(
                (float)
                    (TOP_LEFT_USER_GRID_X
                        + (CONSTANT.GAME_WORLD_WIDTH * (1.5 / 35.0))
                        + (counter * CONSTANT.GAME_WORLD_WIDTH * (3.0 / 35.0))),
                (float) (TOP_LEFT_USER_GRID_Y + (CONSTANT.GAME_WORLD_HEIGHT * (9.0 / 35.0)))));
      }
    }

    shapeCreator.end();
  }
Beispiel #23
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();
 }
Beispiel #24
0
 @Override
 public void render(float delta) {
   if (null != data) {
     Gdx.gl.glEnable(GL10.GL_BLEND);
     render.setColor(colorInner);
     render.begin(ShapeType.FilledTriangle);
     render.filledTriangle(
         data.center.x + width * MathUtils.cosDeg(triangleAngle - 30),
         data.center.y + width * MathUtils.sinDeg(triangleAngle - 30),
         data.center.x + width * MathUtils.cosDeg(triangleAngle + 90),
         data.center.y + width * MathUtils.sinDeg(triangleAngle + 90),
         data.center.x + width * MathUtils.cosDeg(triangleAngle + 210),
         data.center.y + width * MathUtils.sinDeg(triangleAngle + 210));
     render.end();
     render.setColor(colorOuter);
     render.begin(ShapeType.Circle);
     render.circle(data.center.x, data.center.y, width);
     render.end();
     Gdx.gl.glDisable(GL10.GL_BLEND);
   }
 }
Beispiel #25
0
  private void renderWorld() {
    clearScreen();
    sr.setProjectionMatrix(camera.combined);

    mapRenderer.setView(camera);
    mapRenderer.render();

    sr.begin(ShapeType.Filled);
    renderNeighbourCollisionAreas(sr);
    renderPlayer(sr);
    sr.end();
  }
Beispiel #26
0
 @Override
 public void render(
     float delta, OrthographicCamera camera, GDXRenderer gdxRenderer, ShapeRenderer renderer) {
   if (!screen.isLive()) {
     renderer.setProjectionMatrix(camera.combined);
     renderer.begin(ShapeType.Line);
     for (GDXPath object : screen.getLevel().getPaths())
       renderNodeList(object.getNodes(), renderer, Color.GRAY);
     if (pathWindow != null) renderNodeList(pathWindow.getNodes(), renderer, Color.DARK_GRAY);
     renderer.end();
   }
 };
Beispiel #27
0
  public void cleanBorders() {
    shapeRenderer.begin(ShapeType.FilledRectangle);
    shapeRenderer.setColor(Color.BLACK);
    shapeRenderer.filledRect(0, 0, border - 1, Sizes.DEFAULT_WORLD_HEIGHT * ppux);
    shapeRenderer.filledRect(
        border + Sizes.DEFAULT_WORLD_WIDTH * ppux,
        0,
        2 * border + Sizes.DEFAULT_WORLD_WIDTH * ppux,
        Sizes.DEFAULT_WORLD_HEIGHT * ppux);

    shapeRenderer.end();
  }
  private void drawGrid() {
    int height = GdxController.getInstance().getMapGdx().getForeground().getHeight();
    int width = GdxController.getInstance().getMapGdx().getForeground().getWidth();

    shapeRenderer.begin(ShapeType.Line);
    shapeRenderer.setColor(Color.RED);
    for (int i = 0; i < 50; i++) {
      shapeRenderer.line(0.0f, i * 32.0f, width * 32.0f, i * 32.0f);
      shapeRenderer.line(i * 32.0f, 0.0f, i * 32.0f, height * 32.0f);
    }
    shapeRenderer.end();
  }
Beispiel #29
0
  public void draw(
      final Ship ship,
      final StarManager starManager,
      final EnemyManager enemyManager,
      final PowerUpManager powerupManager,
      final ShotManager shotManager,
      final GamePhase phase,
      final GameController controller) {
    if (phase == GamePhase.GAMING) {
      shotManager.drawShape(shapeRenderer, ppux, ppuy, border);
      powerupManager.drawShape(shapeRenderer, ppux, ppuy, border);

      shapeRenderer.begin(ShapeType.FilledRectangle);
      enemyManager.drawHealthBar(shapeRenderer, ppux, ppuy, border);
      shapeRenderer.end();
    }
    shapeRenderer.setColor(Color.WHITE);
    starManager.drawShape(shapeRenderer, ppux, ppuy, border);
    ship.drawShape(shapeRenderer, ppux, ppuy, border);

    batch.begin();
    ship.drawSprite(batch, ppux, ppuy, border);
    switch (phase) {
      case LEVEL_LOAD: // just waiting for refresh
      case GAMING:
        shotManager.drawSprite(batch, ppux, ppuy, border);
        powerupManager.drawSprite(batch, ppux, ppuy, border);
        enemyManager.drawSprite(batch, ppux, ppuy, border);
        break;
      case PAUSE:
        drawPauseTextBox();
        break;
      case LEVEL_SCORE:
        // TODO make counter and stuff and at the end change phase
        //			score =
        GameScreen.updatePhase(GamePhase.LEVEL_WAIT);
      case LEVEL_WAIT:
        drawLevelScore(controller, controller.getTimeBonus());
        break;
      case DEAD:
        // TODO death animation
        drawGameOver();
        break;
      case FINISHED:
        drawGameFinished();
        break;
      case GAMESTART:
        break;
      default:
        break;
    }
    batch.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;
    }
  }