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

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer. These examples are extracted from open source projects. 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 Project: ud405   Source File: Player.java    License: 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 Project: ud405   Source File: SierpinskiTriangle.java    License: 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 3
Source Project: mini2Dx   Source File: LibgdxGraphics.java    License: 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 4
Source Project: talos   Source File: ShapeWidget.java    License: 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 5
Source Project: ud405   Source File: Player.java    License: 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 Project: riiablo   Source File: Animation.java    License: 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 7
Source Project: skin-composer   Source File: GradientDrawable.java    License: 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 8
Source Project: Entitas-Java   Source File: DebugRendererSystem.java    License: 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 9
Source Project: GdxDemo3D   Source File: LoadingGameScreen.java    License: 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 10
Source Project: ud405   Source File: Player.java    License: 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 Project: ud406   Source File: RectangleCircleCollisionScreen.java    License: 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 12
Source Project: ud405   Source File: Player.java    License: 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 13
Source Project: gdx-vfx   Source File: TransformScalableWrapper.java    License: 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 Project: ud405   Source File: PointDrawing.java    License: MIT License 5 votes vote down vote up
/**
 * This is called when the application is ready for us to start up. Anything you'd do in a
 * constructor, do in create instead.
 */
@Override
public void create() {
    Gdx.app.log(TAG, "Application Listener Created");
    // Never allocate anything in render, since that gets called 60 times a second
    shapeRenderer = new ShapeRenderer();
}
 
Example 15
Source Project: libGDX-Path-Editor   Source File: SplineRenderer.java    License: Apache License 2.0 5 votes vote down vote up
public SplineRenderer(PathSpline spline, String controlColorHex, String segmentColorHex, String selectColorHex) {
	this.spline = spline;
	java.awt.Color tempControlColor = java.awt.Color.decode(controlColorHex);
	this.controlColor = new Color(tempControlColor.getRed()/255f, tempControlColor.getGreen()/255f, tempControlColor.getBlue()/255f, 1f);
	java.awt.Color tempSegmentColor = java.awt.Color.decode(segmentColorHex);
	this.segmentColor = new Color(tempSegmentColor.getRed()/255f, tempSegmentColor.getGreen()/255f, tempSegmentColor.getBlue()/255f, 1f);
	java.awt.Color tempSelectColor  = java.awt.Color.decode(selectColorHex);
	this.selectColor  = new Color(tempSelectColor.getRed()/255f, tempSelectColor.getGreen()/255f, tempSelectColor.getBlue()/255f, 1f);
	renderer = new ShapeRenderer();
}
 
Example 16
Source Project: seventh   Source File: GdxCanvas.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
     * 
     */
    public GdxCanvas() {
        this.batch = new SpriteBatch();
        this.color = new Color();
        this.tmpColor = new Color();
        
        this.shaderStack = new Stack<>();
        this.zoomStack = new Stack<>();
        
        this.camera = new OrthographicCamera(getWidth(), getHeight());
        this.camera.setToOrtho(true, getWidth(), getHeight());
        this.camera.position.x = this.camera.viewportWidth/2;
        this.camera.position.y = this.camera.viewportHeight/2;
        this.camera.update();
        
        this.viewport = new FitViewport(getWidth(), getHeight(), camera);
        this.viewport.apply();
                
        this.generators = new HashMap<String, FreeTypeFontGenerator>();
        this.fonts = new HashMap<String, BitmapFont>();
        this.bounds = new GlyphLayout();
                
        this.transform = new Matrix4();
        //this.batch.setTransformMatrix(transform);
                
        //Matrix4 projection = new Matrix4();
        //projection.setToOrtho( 0, getWidth(), getHeight(), 0, -1, 1);
        //this.batch.setProjectionMatrix(projection);
        
//        this.wHeight = getHeight();
        this.batch.setProjectionMatrix(this.camera.combined);
        
        this.shapes = new ShapeRenderer();
        //this.shapes.setTransformMatrix(transform);    
//        this.shapes.setProjectionMatrix(projection);
        //this.shapes.setProjectionMatrix(camera.combined);
        
        this.fbo = new FrameBuffer(Format.RGBA8888, getWidth(), getHeight(), false);
    }
 
Example 17
Source Project: ud405   Source File: Icicle.java    License: 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 18
Source Project: gdx-gltf   Source File: GLTFDemo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	GLProfiler profiler = new GLProfiler(Gdx.graphics);
	profiler.setListener(new GLErrorListener() {
		@Override
		public void onError(int error) {
			Gdx.app.error("OpenGL", String.valueOf(error));
		}
	});
	profiler.enable();
	
	assetManager = new AssetManager();
	Texture.setAssetManager(assetManager);
	
	assetManager.setLoader(SceneAsset.class, ".gltf", new GLTFAssetLoader());
	assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
	
	shapeRenderer = new ShapeRenderer();
	
	spriteBatch = new SpriteBatch();
	
	createSceneManager();
	
	createUI();
	
	loadModelIndex();
}
 
Example 19
Source Project: ud405   Source File: IciclesScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    player = new Player(iciclesViewport);
    icicle = new Icicle(new Vector2(Constants.WORLD_SIZE / 2, Constants.WORLD_SIZE / 2));

}
 
Example 20
Source Project: bladecoder-adventure-engine   Source File: CanvasDrawer.java    License: Apache License 2.0 5 votes vote down vote up
public void drawBGBounds() {
	// Gdx.gl20.glEnable(GL20.GL_BLEND);
	// Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

	drawer.setProjectionMatrix(camera.combined);
	drawer.setTransformMatrix(new Matrix4());

	drawer.begin(ShapeRenderer.ShapeType.Line);
	drawer.setColor(Color.MAGENTA);
	drawer.rect(0, 0, Ctx.project.getWorld().getWidth(), Ctx.project.getWorld().getHeight());
	drawer.end();
}
 
Example 21
Source Project: ud405   Source File: Icicle.java    License: 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 22
Source Project: ud405   Source File: FallingObjectsScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {

    renderer = new ShapeRenderer();
    viewport = new ExtendViewport(WORLD_SIZE, WORLD_SIZE);
    avalanche = new Avalanche();

}
 
Example 23
Source Project: Unlucky   Source File: InventoryUI.java    License: 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 24
Source Project: ud405   Source File: Icicle.java    License: 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 25
Source Project: ud405   Source File: ConnectTheDots.java    License: 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 26
Source Project: ud405   Source File: BubbleLevelScreen.java    License: 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 27
Source Project: ud405   Source File: DifficultyScreen.java    License: 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 28
Source Project: dice-heroes   Source File: GdxHelper.java    License: 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);
}
 
Example 29
Source Project: ud405   Source File: BallScreen.java    License: 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 30
Source Project: ud405   Source File: Player.java    License: 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);
    }