Java Code Examples for com.badlogic.gdx.graphics.glutils.ShapeRenderer#circle()

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer#circle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 2
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 3
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 4
Source File: OrthographicProjection.java    From ud405 with MIT License 6 votes vote down vote up
/**
 * This method renders a few shapes for us to try our camera on. Note that we're using a Bezier
 * curve, which is a way to draw smooth curves. For more information on Bezier curves, check
 * out: https://en.wikipedia.org/wiki/B%C3%A9zier_curve
 *
 * Also note that a line is a line is a line. No matter how much we zoom in, a line is always
 * just one pixel wide.
 */
private void renderTestScene(ShapeRenderer renderer) {
    renderer.begin(ShapeType.Filled);
    renderer.setColor(Color.GREEN);
    renderer.circle(100, 100, 90);
    renderer.setColor(Color.RED);
    renderer.rect(200, 10, 200, 200);
    renderer.setColor(Color.YELLOW);
    renderer.triangle(10, 200, 200, 200, 100, 400);
    renderer.end();
    renderer.begin(ShapeType.Line);

    renderer.setColor(Color.CYAN);

    // Here's another shape ShapeRenderer
    renderer.curve(
            210, 210,
            400, 210,
            210, 400,
            400, 300,
            20);
    renderer.end();
}
 
Example 5
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 6
Source File: SmileyFace.java    From ud405 with MIT License 6 votes vote down vote up
private void drawSmileyFace(ShapeRenderer renderer) {

        // TODO: Set the color to yellow, and draw the face
        renderer.setColor(Color.YELLOW);
        renderer.circle(FACE_CENTER_X, FACE_CENTER_Y, FACE_RADIUS, FACE_SEGMENTS);

        // TODO: Set the color to black and draw the eyes
        renderer.setColor(Color.BLACK);
        renderer.circle(FACE_CENTER_X - EYE_OFFSET, FACE_CENTER_Y + EYE_OFFSET, EYE_RADIUS, EYE_SEGMENTS);
        renderer.circle(FACE_CENTER_X + EYE_OFFSET, FACE_CENTER_Y + EYE_OFFSET, EYE_RADIUS, EYE_SEGMENTS);

        // TODO: Draw a black arc for the mouth (Hint: MOUTH_OUTER_RADIUS)
        renderer.arc(FACE_CENTER_X, FACE_CENTER_Y, MOUTH_OUTER_RADIUS, MOUTH_START_ANGLE, MOUTH_DEGREES, MOUTH_SEGMENTS);

        // TODO: Draw a yellow arc to make the mouth actually look like a mouth (Hint: MOUTH_INNER_RADIUS)
        renderer.setColor(Color.YELLOW);
        renderer.arc(FACE_CENTER_X, FACE_CENTER_Y, MOUTH_INNER_RADIUS, MOUTH_START_ANGLE, MOUTH_DEGREES, MOUTH_SEGMENTS);
    }
 
Example 7
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 8
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 9
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 10
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 11
Source File: Player.java    From ud405 with MIT License 6 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.PLAYER_COLOR);
    renderer.set(ShapeType.Filled);
    renderer.circle(position.x, position.y, Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_HEAD_SEGMENTS);

    Vector2 torsoTop = new Vector2(position.x, position.y - Constants.PLAYER_HEAD_RADIUS);
    Vector2 torsoBottom = new Vector2(torsoTop.x, torsoTop.y - 2 * Constants.PLAYER_HEAD_RADIUS);

    renderer.rectLine(torsoTop, torsoBottom, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x + Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
    renderer.rectLine(
            torsoTop.x, torsoTop.y,
            torsoTop.x - Constants.PLAYER_HEAD_RADIUS, torsoTop.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x + Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);

    renderer.rectLine(
            torsoBottom.x, torsoBottom.y,
            torsoBottom.x - Constants.PLAYER_HEAD_RADIUS, torsoBottom.y - Constants.PLAYER_HEAD_RADIUS, Constants.PLAYER_LIMB_WIDTH);
}
 
Example 12
Source File: DirectionActor.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void drawDebug(ShapeRenderer shapes) {
  //super.drawDebug(shapes);
  if (!isVisible()) return;

  float cx = getX() + r;
  float cy = getY() + r;

  shapes.setColor(Color.WHITE);
  shapes.set(ShapeRenderer.ShapeType.Filled);
  shapes.circle(cx, cy, r, 64);
  shapes.set(ShapeRenderer.ShapeType.Line);

  float snap = Direction.snapToDirection(angle, dirs);
  float dx = r * MathUtils.cos(snap);
  float dy = r * MathUtils.sin(snap);

  shapes.setColor(Color.BLUE);
  shapes.line(cx, cy, cx + dx, cy + dy);

  if (DEBUG_ANGLE) {
    dx = r * MathUtils.cos(angle);
    dy = r * MathUtils.sin(angle);

    shapes.setColor(Color.BLACK);
    shapes.line(cx, cy, cx + dx, cy + dy);
  }
}
 
Example 13
Source File: CircularMotion.java    From ud405 with MIT License 5 votes vote down vote up
private void drawFancyCircles(ShapeRenderer renderer, float elapsedPeriods, int circleCount) {
    for (int i = 1; i <= circleCount; i++) {
        float centerX = WORLD_SIZE / 2 + WORLD_SIZE / 4 * MathUtils.cos(MathUtils.PI2 * i / circleCount);
        float centerY = WORLD_SIZE / 2 + WORLD_SIZE / 4 * MathUtils.sin(MathUtils.PI2 * i / circleCount);

        float x = centerX + WORLD_SIZE / 5 * MathUtils.cos(MathUtils.PI2 * (elapsedPeriods * i / circleCount));
        float y = centerY + WORLD_SIZE / 5 * MathUtils.sin(MathUtils.PI2 * (elapsedPeriods * i / circleCount));

        renderer.circle(x, y, 10);
    }
}
 
Example 14
Source File: BouncingBall.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.set(ShapeType.Filled);
    renderer.setColor(COLOR);
    renderer.circle(position.x, position.y, radius);
}
 
Example 15
Source File: Boulder.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer){
    renderer.set(ShapeType.Filled);
    renderer.setColor(COLOR);
    renderer.circle(position.x, position.y, radius);
}
 
Example 16
Source File: BouncingBall.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer shapeRenderer){
    shapeRenderer.set(ShapeType.Filled);
    shapeRenderer.setColor(Color.RED);
    shapeRenderer.circle(position.x, position.y, radius, 20);
}
 
Example 17
Source File: BouncingBall.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.set(ShapeType.Filled);
    renderer.setColor(COLOR);
    renderer.circle(position.x, position.y, radius);
}
 
Example 18
Source File: BouncingBall.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.set(ShapeType.Filled);
    renderer.setColor(COLOR);
    renderer.circle(position.x, position.y, baseRadius * radiusMultiplier);
}
 
Example 19
Source File: BouncingBall.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.set(ShapeType.Filled);
    renderer.setColor(COLOR);
    renderer.circle(position.x, position.y, radius);
}
 
Example 20
Source File: BouncingBall.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.set(ShapeType.Filled);
    renderer.setColor(COLOR);
    renderer.circle(position.x, position.y, baseRadius * radiusMultiplier);
}