com.badlogic.gdx.graphics.glutils.ShapeRenderer Java Examples

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer. 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: LibgdxGraphics.java    From mini2Dx with Apache License 2.0 6 votes vote down vote up
private void setupDepthBuffer() {
	if (clip != null) {
		Gdx.gl.glDepthFunc(GL20.GL_LESS);
		Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

		Gdx.gl.glDepthMask(true);
		Gdx.gl.glColorMask(false, false, false, false);

		shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);

		shapeRenderer.setColor(0f, 1f, 0f, 0.5f);
		shapeRenderer.rect(clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight());

		shapeRenderer.end();

		Gdx.gl.glColorMask(true, true, true, true);
		Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
		Gdx.gl.glDepthFunc(GL20.GL_EQUAL);
	}
}
 
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: 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 #5
Source File: SierpinskiTriangle.java    From ud405 with MIT License 6 votes vote down vote up
private void drawSierpinskiTriangle(ShapeRenderer shapeRenderer, Vector2 corner1, Vector2 corner2, Vector2 corner3, int recursions) {

        Vector2 midpoint12 = new Vector2((corner1.x + corner2.x) / 2, (corner1.y + corner2.y) / 2);
        Vector2 midpoint23 = new Vector2((corner2.x + corner3.x) / 2, (corner2.y + corner3.y) / 2);
        Vector2 midpoint31 = new Vector2((corner3.x + corner1.x) / 2, (corner3.y + corner1.y) / 2);

        if (recursions == 1) {
            shapeRenderer.triangle(corner1.x, corner1.y, midpoint12.x, midpoint12.y, midpoint31.x, midpoint31.y);
            shapeRenderer.triangle(corner2.x, corner2.y, midpoint23.x, midpoint23.y, midpoint12.x, midpoint12.y);
            shapeRenderer.triangle(corner3.x, corner3.y, midpoint31.x, midpoint31.y, midpoint23.x, midpoint23.y);
        } else {
            drawSierpinskiTriangle(shapeRenderer, corner1, midpoint12, midpoint31, recursions - 1);
            drawSierpinskiTriangle(shapeRenderer, corner2, midpoint23, midpoint12, recursions - 1);
            drawSierpinskiTriangle(shapeRenderer, corner3, midpoint31, midpoint23, recursions - 1);
        }

    }
 
Example #6
Source File: ShapeWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
    tmp.set(0, 0);
    localToStageCoordinates(tmp);

    drawBg(batch, parentAlpha);

    batch.end();
    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

    drawGrid(batch, parentAlpha);
    drawShape(batch, parentAlpha);
    drawTools(batch, parentAlpha);

    shapeRenderer.end();
    batch.begin();

}
 
Example #7
Source File: DebugRendererSystem.java    From Entitas-Java with MIT License 6 votes vote down vote up
public DebugRendererSystem(Entitas entitas, World world, Batch batch) {
    this.physics = world;
    this.entitas = entitas;
    this.batch = batch;

    this.shapeRenderer = new ShapeRenderer();
    this.debugRenderer = new Box2DDebugRenderer(DRAW_BOX2D_BODIES, DRAW_BOX2D_JOINTS, DRAW_BOX2D_ABBs,
            DRAW_BOX2D_INACTIVE_BODIES, DRAW_BOX2D_VELOCITIES, DRAW_BOX2D_CONTACTS);
    debugRenderer.setDrawAABBs(DRAW_BOX2D_ABBs);
    debugRenderer.setDrawBodies(DRAW_BOX2D_BODIES);
    debugRenderer.setDrawContacts(DRAW_BOX2D_CONTACTS);
    debugRenderer.setDrawInactiveBodies(DRAW_BOX2D_INACTIVE_BODIES);
    debugRenderer.setDrawJoints(DRAW_BOX2D_JOINTS);
    debugRenderer.setDrawVelocities(DRAW_BOX2D_VELOCITIES);

}
 
Example #8
Source File: LoadingGameScreen.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
@Override
public void renderProgress (float delta, float progress) {
	Gdx.gl.glClearColor(Color.BLACK.r, Color.BLACK.g, Color.BLACK.b, Color.BLACK.a);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	shapeRenderer.setProjectionMatrix(camera.projection);
	shapeRenderer.setTransformMatrix(camera.view);
	shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
	float x = (GdxDemo3D.WIDTH - PROGRESS_BAR_WIDTH) / 2;
	float y = (GdxDemo3D.HEIGHT - PROGRESS_BAR_HEIGHT) / 2;
	float k = 4;
	shapeRenderer.setColor(Color.WHITE);
	shapeRenderer.rect(x - k, y - k, PROGRESS_BAR_WIDTH + k * 2, PROGRESS_BAR_HEIGHT + k * 2);
	shapeRenderer.setColor(Color.BLUE);
	shapeRenderer.rect(x, y, PROGRESS_BAR_WIDTH * progress, PROGRESS_BAR_HEIGHT);
	shapeRenderer.end();
}
 
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: GradientDrawable.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public void draw(Batch batch, float x, float y, float width, float height) {
    float[] alphas = {col1.a, col2.a, col3.a, col4.a};
    col1.a = batch.getColor().a * col1.a;
    col2.a = batch.getColor().a * col2.a;
    col3.a = batch.getColor().a * col3.a;
    col4.a = batch.getColor().a * col4.a;
    
    g.begin(ShapeRenderer.ShapeType.Filled);
    g.setProjectionMatrix(batch.getProjectionMatrix());
    g.setTransformMatrix(batch.getTransformMatrix());
    batch.end();
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    g.rect(x + borderLeft, y + borderBottom, width - borderLeft - borderRight, height - borderBottom - borderTop, col1, col2, col3, col4);
    g.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    
    col1.a = alphas[0];
    col2.a = alphas[1];
    col3.a = alphas[2];
    col4.a = alphas[3];
}
 
Example #11
Source File: Animation.java    From riiablo with Apache License 2.0 6 votes vote down vote up
protected void drawDebug(ShapeRenderer shapeRenderer, int d, int f, float x, float y) {
  boolean reset = !shapeRenderer.isDrawing();
  if (reset) {
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
  } else {
    shapeRenderer.set(ShapeRenderer.ShapeType.Line);
  }

  shapeRenderer.setColor(Color.RED);
  shapeRenderer.line(x, y, x + 40, y);
  shapeRenderer.setColor(Color.GREEN);
  shapeRenderer.line(x, y, x, y + 20);
  shapeRenderer.setColor(Color.BLUE);
  shapeRenderer.line(x, y, x + 20, y - 10);

  BBox box = dc.getBox(d, f);
  shapeRenderer.setColor(DEBUG_COLOR);
  shapeRenderer.rect(x + box.xMin, y - box.yMax, box.width, box.height);
  if (reset) shapeRenderer.end();
}
 
Example #12
Source File: RectangleCircleCollisionScreen.java    From ud406 with MIT License 6 votes vote down vote up
public RectangleCircleCollisionScreen() {
    startTime = TimeUtils.nanoTime();
    shapeRenderer = new ShapeRenderer();
    viewport = new FitViewport(WORLD_SIZE, WORLD_SIZE);

    rectangles = new Array<Rectangle>(new Rectangle[]{
            new Rectangle(40, 40, 20, 20), // Middle
            new Rectangle(10, 40, 10, 20), // Left
            new Rectangle(70, 45, 20, 10) // Right
    });

    circles = new Array<OscillatingCircle>(new OscillatingCircle[]{
            new OscillatingCircle(50, 65, 7, 0, 40, 3), // High horizontal
            new OscillatingCircle(50, 35, 7, 0, 40, 3.1f), // Low horizontal
            new OscillatingCircle(50, 50, 3, MathUtils.PI / 4, 40, 5f), // Diagonal
            new OscillatingCircle(25, 50, 5, 0, 11, 7f), // Middle horizontal
    });
}
 
Example #13
Source File: TransformScalableWrapper.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
protected void drawDebugBounds(ShapeRenderer shapes) {
    if (!getDebug()) return;
    shapes.set(ShapeRenderer.ShapeType.Line);
    shapes.setColor(getStage().getDebugColor());
    shapes.rect(getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), 1f, 1f, getRotation());
}
 
Example #14
Source File: DifficultyScreen.java    From ud405 with MIT License 5 votes vote down vote up
@Override
public void show() {
    renderer = new ShapeRenderer();
    batch = new SpriteBatch();

    // TODO: Initialize a FitViewport with the difficulty world size constant
    viewport = new FitViewport(Constants.DIFFICULTY_WORLD_SIZE, Constants.DIFFICULTY_WORLD_SIZE);
    Gdx.input.setInputProcessor(this);

    font = new BitmapFont();
    // TODO: Set the font scale using the constant we defined
    font.getData().setScale(Constants.DIFFICULTY_LABEL_SCALE);
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
}
 
Example #15
Source File: BallScreen.java    From ud405 with MIT License 5 votes vote down vote up
@Override
public void show() {
    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);
    viewport = new ExtendViewport(WORLD_SIZE, WORLD_SIZE);
    ball = new BouncingBall(viewport);
}
 
Example #16
Source File: Player.java    From ud405 with MIT License 5 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 #17
Source File: BallScreen.java    From ud405 with MIT License 5 votes vote down vote up
@Override
public void show() {
    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);
    viewport = new ExtendViewport(WORLD_SIZE, WORLD_SIZE);
    ball = new BouncingBall(viewport);
    Gdx.input.setInputProcessor(ball);
}
 
Example #18
Source File: GameScreen.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
@Override
public void render(float delta) {
	camera.update(delta * GameSettings.CAMERA_LERP_ALPHA);
	stage.act(delta);

	delta *= GameSettings.GAME_SPEED;
	Gdx.gl.glClearColor(0, 0, 0, 1f);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

	viewportBackgroundRenderer.begin(ShapeRenderer.ShapeType.Filled);
	viewportBackgroundRenderer.setColor(viewportBackgroundColor);
	viewportBackgroundRenderer.rect(0, 0, viewport.getScreenWidth(), viewport.getScreenHeight());
	viewportBackgroundRenderer.end();

	engine.update(delta);
	renderer.update(delta);

	if (DebugViewSettings.drawCollShapes || DebugViewSettings.drawConstraints) {
		int mode = 0;
		if (DebugViewSettings.drawConstraints) {
			mode |= DebugDrawModes.DBG_DrawConstraints;
			mode |= DebugDrawModes.DBG_DrawConstraintLimits;
		}
		if (DebugViewSettings.drawCollShapes) {
			mode |= DebugDrawModes.DBG_DrawWireframe;
		}
		engine.setDebugMode(mode);
		engine.debugDrawWorld(camera);
	}
	stage.draw();

}
 
Example #19
Source File: DirectionTool.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void render() {
  Gdx.gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

  float radius = 64;
  float angle = MathUtils.atan2(y2 - y1, x2 - x1);
  float x = radius * MathUtils.cos(angle);
  float y = radius * MathUtils.sin(angle);

  builder.setLength(0);
  builder
      .append("x,y: ").append("(" + x2 + "," + y2 + ")").append('\n')
      .append("angle: ").append(angle).append('\n')
      .append("dir4: ").append(Direction.radiansToDirection(angle, 4)).append('\n')
      .append("dir8: ").append(Direction.radiansToDirection(angle, 8)).append('\n')
      .append("dir16: ").append(Direction.radiansToDirection(angle, 16)).append('\n')
      .append("dir32: ").append(Direction.radiansToDirection(angle, 32)).append('\n');

  shapes.begin(ShapeRenderer.ShapeType.Line);
  drawDiamond(shapes, x1 - 80, y1 - 40, 160, 80);
  shapes.line(x1, y1, x1 + x, y1 + y);
  shapes.end();

  batch.begin();
  font.draw(batch, builder.toString(), 0, Gdx.graphics.getHeight());
  batch.end();
}
 
Example #20
Source File: CheckerBoard.java    From ud405 with MIT License 5 votes vote down vote up
public static void render(ShapeRenderer renderer, Vector2 bottomLeft, Vector2 topRight, float squareSize){
    int yIndex = 0;
    for (float yStart = bottomLeft.y; yStart < topRight.y; yStart += squareSize){
        yIndex++;
        int xIndex = 0;
        for (float xStart = bottomLeft.x; xStart < topRight.x; xStart += squareSize){
            xIndex++;
            if ((xIndex + yIndex) % 2 == 0){
                renderer.rect(xStart, yStart, squareSize, squareSize);

            }
        }
    }
}
 
Example #21
Source File: DemoCamera.java    From ud405 with MIT License 5 votes vote down vote up
/**
 * Set's the ShapeRenderer's projection matrix depending on the mode of the demo camera.
 */
public void setCamera(ShapeRenderer renderer) {
    if (inCloseupMode) {
        closeupCamera.update();
        renderer.setProjectionMatrix(closeupCamera.combined);
    } else {
        overviewCamera.update();
        renderer.setProjectionMatrix(overviewCamera.combined);
    }
}
 
Example #22
Source File: BubbleLevelScreen.java    From ud405 with MIT License 5 votes vote down vote up
@Override
public void show() {
    axisViewport = new FitViewport(WORLD_SIZE, WORLD_SIZE);
    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);
    batch = new SpriteBatch();
    textViewport = new ScreenViewport();
    font = new BitmapFont();
    font.getData().setScale(TEXT_SCALE);
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    maxAcceleration = 0;
    minAcceleration = Float.MAX_VALUE;

}
 
Example #23
Source File: ConnectTheDots.java    From ud405 with MIT License 5 votes vote down vote up
@Override
public void create () {
    spriteBatch = new SpriteBatch();
    bitmapFont = new BitmapFont();
    floatDots = vector2ArrayToFloatArray(dots);
    shapeRenderer = new ShapeRenderer();
}
 
Example #24
Source File: Level.java    From ud406 with MIT License 5 votes vote down vote up
public void render(SpriteBatch batch, ShapeRenderer renderer) {

        renderer.begin(ShapeType.Filled);
        // TODO: Render all platforms in the platform array
        for (Platform platform : platforms) {
            platform.render(renderer);
        }
        renderer.end();

        batch.begin();
        gigaGal.render(batch);
        batch.end();
    }
 
Example #25
Source File: Entity.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void drawDebugTarget(ShapeRenderer shapes) {
  if (target.isZero() || !path.isEmpty()) return;
  EngineUtils.worldToScreenCoords(target, tmpVec2);
  shapes.set(ShapeRenderer.ShapeType.Filled);
  shapes.setColor(Color.ORANGE);
  shapes.rectLine(screen.x, screen.y, tmpVec2.x, tmpVec2.y, 1);
  shapes.set(ShapeRenderer.ShapeType.Line);
}
 
Example #26
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example #27
Source File: InventoryUI.java    From Unlucky with MIT License 5 votes vote down vote up
public void render(float dt) {
    if (!inMenu) {
        stage.act(dt);
        stage.draw();
    }

    if (renderHealthBars) {
        // draw bars
        shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
        // health bar
        shapeRenderer.setColor(60 / 255.f, 60 / 255.f, 60 / 255.f, 1);
        shapeRenderer.rect(ui.getX() + 8, ui.getY() + 88, maxBarWidth, 2);
        shapeRenderer.setColor(0, 225 / 255.f, 0, 1);
        shapeRenderer.rect(ui.getX() + 8, ui.getY() + 89, hpBarWidth, 1);
        shapeRenderer.setColor(0, 175 / 255.f, 0, 1);
        shapeRenderer.rect(ui.getX() + 8, ui.getY() + 88, hpBarWidth, 1);
        // exp bar
        shapeRenderer.setColor(60 / 255.f, 60 / 255.f, 60 / 255.f, 1);
        shapeRenderer.rect(ui.getX() + 8, ui.getY() + 80, maxBarWidth, 2);
        shapeRenderer.setColor(1, 212 / 255.f, 0, 1);
        shapeRenderer.rect(ui.getX() + 8, ui.getY() + 81, expBarWidth, 1);
        shapeRenderer.setColor(200 / 255.f, 170 / 255.f, 0, 1);
        shapeRenderer.rect(ui.getX() + 8, ui.getY() + 80, expBarWidth, 1);
        shapeRenderer.end();
    }
}
 
Example #28
Source File: GameplayScreen.java    From ud406 with MIT License 5 votes vote down vote up
@Override
public void show() {
    AssetManager am = new AssetManager();
    Assets.instance.init(am);
    level = new Level();
    batch = new SpriteBatch();
    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);
    viewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);
}
 
Example #29
Source File: SystemProfilerGUI.java    From riiablo with Apache License 2.0 5 votes vote down vote up
private void drawGraphAxis(ShapeRenderer renderer, float x, float y, float width, float height, float alpha) {
  float sep = height / 7;
  y += sep / 2;
  renderer.setColor(GRAPH_V_LINE.r, GRAPH_V_LINE.g, GRAPH_V_LINE.b, alpha);
  renderer.line(x, y, x, y + height - sep);
  renderer.line(x + width, y, x + width, y + height - sep);

  renderer.setColor(GRAPH_H_LINE.r, GRAPH_H_LINE.g, GRAPH_H_LINE.b, alpha);
  for (int i = 0; i < 7; i++) {
    renderer.line(x, y + i * sep, x + width, y + i * sep);
  }
}
 
Example #30
Source File: GdxHelper.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static void showStageEvents(final Stage stage) {
    EventListener listener = new EventListener() {
        private final Vector2 tmp = new Vector2();
        private Actor actor = new Actor() {
            @Override public void draw(Batch batch, float parentAlpha) {
                if (target == null)
                    return;
                batch.end();
                Config.shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
                Config.shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
                Gdx.gl.glLineWidth(6);
                Config.shapeRenderer.setColor(Color.ORANGE);
                Vector2 pos = target.localToStageCoordinates(tmp.set(0, 0));
                float x = pos.x, y = pos.y;
                Vector2 top = target.localToStageCoordinates(tmp.set(target.getWidth(), target.getHeight()));
                float maxX = top.x, maxY = top.y;
                Config.shapeRenderer.rect(x, y, maxX - x, maxY - y);

                Config.shapeRenderer.end();
                batch.begin();
            }
        };

        {
            stage.addActor(actor);
        }

        public Actor target;

        @Override public boolean handle(Event event) {
            target = event.getTarget();
            return false;
        }
    };
    stage.addListener(listener);
}