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

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer#setColor() . 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: 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: Cursor.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void render(PaletteIndexedBatch batch) {
  if (dc != null) {
    BBox box = dc.getBox();
    coords.set(Gdx.input.getX(), Gdx.input.getY());
    Riiablo.extendViewport.unproject(coords);
    coords.sub(box.width / 2f, box.height / 2f);

    batch.begin();
    batch.setColormap(transform, transformColor);
    if (item.isEthereal()) batch.setAlpha(Item.ETHEREAL_ALPHA);
    batch.draw(dc.getTexture(), coords.x, coords.y);
    if (item.isEthereal()) batch.resetColor();
    batch.resetColormap();
    batch.end();

    if (DEBUG_ITEM_BOUNDS) {
      ShapeRenderer shapes = Riiablo.shapes;
      shapes.setProjectionMatrix(Riiablo.extendViewport.getCamera().combined);
      shapes.begin(ShapeRenderer.ShapeType.Line);
      shapes.setColor(Color.GREEN);
      shapes.rect(coords.x, coords.y, box.width, box.height);
      shapes.end();
    }
  }
}
 
Example 6
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 7
Source File: EntityStage.java    From Norii with Apache License 2.0 5 votes vote down vote up
public void drawEntitiesDebug() {
	final Array<Actor> actors = getActors();
	final ShapeRenderer debugRenderer = new ShapeRenderer();
	debugRenderer.setProjectionMatrix(getCamera().combined);
	debugRenderer.setColor(Color.RED);
	debugRenderer.begin(ShapeType.Line);
	for (final Actor actor : actors) {
		actor.debug();
		actor.drawDebug(debugRenderer);
	}
	debugRenderer.end();
}
 
Example 8
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {

        // TODO: Set the ShapeRenderer's color
        renderer.setColor(Constants.ICICLE_COLOR);

        // TODO: Set the ShapeType
        renderer.set(ShapeType.Filled);

        // TODO: Draw the icicle using the size constants
        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 9
Source File: Animation.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void drawDebug(ShapeRenderer shapes, float x, float y) {
  if (DEBUG_MODE == 0) {
    return;
  } else if (DEBUG_MODE == 1 || cof == null) {
    boolean reset = !shapes.isDrawing();
    if (reset) {
      shapes.begin(ShapeRenderer.ShapeType.Line);
    } else {
      shapes.set(ShapeRenderer.ShapeType.Line);
    }

    shapes.setColor(Color.RED);
    shapes.line(x, y, x + 50, y);
    shapes.setColor(Color.GREEN);
    shapes.line(x, y, x, y + 50);
    shapes.setColor(Color.BLUE);
    shapes.line(x, y, x + 15, y - 20);
    shapes.setColor(Color.GREEN);
    shapes.rect(x + box.xMin, y - box.yMax, box.width, box.height);
    if (reset) shapes.end();
  } else if (DEBUG_MODE == 2 && frame < numFrames) {
    int d = DC.Direction.toReadDir(direction, cof.getNumDirections());
    int f = frame;
    for (int l = 0; l < cof.getNumLayers(); l++) {
      int component = cof.getLayerOrder(d, f, l);
      Layer layer = layers[component];
      if (layer != null) layer.drawDebug(shapes, d, f, x, y);
    }
  }
}
 
Example 10
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 11
Source File: Icicles.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.ICICLE_COLOR);
    for (Icicle icicle : icicleList) {
        icicle.render(renderer);
    }
}
 
Example 12
Source File: Icicles.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.ICICLE_COLOR);
    for (Icicle icicle : icicleList) {
        icicle.render(renderer);
    }
}
 
Example 13
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 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, baseRadius * radiusMultiplier);
}
 
Example 15
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 16
Source File: Icicles.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.ICICLE_COLOR);
    for (Icicle icicle : icicleList) {
        icicle.render(renderer);
    }
}
 
Example 17
Source File: Icicles.java    From ud405 with MIT License 4 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.setColor(Constants.ICICLE_COLOR);
    for (Icicle icicle : icicleList) {
        icicle.render(renderer);
    }
}
 
Example 18
Source File: Scene.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public void drawBBoxLines(ShapeRenderer renderer) {
	// renderer.begin(ShapeType.Rectangle);
	renderer.begin(ShapeType.Line);

	for (BaseActor a : actors.values()) {
		Polygon p = a.getBBox();

		if (p == null) {
			EngineLogger.error("ERROR DRAWING BBOX FOR: " + a.getId());
		}

		if (a instanceof ObstacleActor) {
			renderer.setColor(OBSTACLE_COLOR);
			renderer.polygon(p.getTransformedVertices());
		} else if (a instanceof AnchorActor) {
			renderer.setColor(Scene.ANCHOR_COLOR);
			renderer.line(p.getX() - Scene.ANCHOR_RADIUS, p.getY(), p.getX() + Scene.ANCHOR_RADIUS, p.getY());
			renderer.line(p.getX(), p.getY() - Scene.ANCHOR_RADIUS, p.getX(), p.getY() + Scene.ANCHOR_RADIUS);
		} else {
			renderer.setColor(ACTOR_BBOX_COLOR);
			renderer.polygon(p.getTransformedVertices());
		}

		// Rectangle r = a.getBBox().getBoundingRectangle();
		// renderer.rect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
	}

	if (walkZone != null) {
		renderer.setColor(WALKZONE_COLOR);
		renderer.polygon(polygonalNavGraph.getWalkZone().getTransformedVertices());

		// DRAW LINEs OF SIGHT
		renderer.setColor(Color.WHITE);
		ArrayList<NavNodePolygonal> nodes = polygonalNavGraph.getGraphNodes();
		for (NavNodePolygonal n : nodes) {
			for (NavNodePolygonal n2 : n.neighbors) {
				renderer.line(n.x, n.y, n2.x, n2.y);
			}
		}
	}

	renderer.end();
}
 
Example 19
Source File: PathSpline.java    From libGDX-Path-Editor with Apache License 2.0 4 votes vote down vote up
public void present(ShapeRenderer renderer, int index, int leftIndex, int rightIndex, renderMode mode,
		 Color controlColor, Color segmentColor, Color selectColor) {
	Vector3 v;
	
	//draw all vertices
	if (totalVertices != null) {
     for (int i=0; i<getSplineVerticesCount()-1; i++) {
         v = totalVertices[i];
         renderer.setColor(segmentColor);
         renderer.filledCircle(v.x, v.y, 4);
     }
    }

	//draw control vertices
    if (controlVertices != null) {
     for (int i=0; i<controlVertices.size(); i++) {
         v = controlVertices.get(i);
         renderer.setColor(controlColor);
         renderer.filledCircle(v.x, v.y, 4);
     }
    }
    
    //draw currently selected vertex
    if ((index != -1) || ((leftIndex != -1) || (rightIndex != -1))) {
    	if ((mode == renderMode.EDIT) || (mode == renderMode.INSERT)) {
    		if (controlVertices != null) {
    	        for (int i=0; i<controlVertices.size(); i++) {
    	        	if (mode == renderMode.EDIT) {
     	        	if (i == index) {
     	        		v = controlVertices.get(i);
     	        		renderer.setColor(selectColor);
  		            renderer.filledCircle(v.x, v.y, 8);
     	        	}
    	        	}
    	        	if (mode == renderMode.INSERT) {
    	        		if (i == leftIndex) {
     	        		v = controlVertices.get(i);
     	        		renderer.setColor(selectColor);
  		            renderer.filledCircle(v.x, v.y, 8);
     	        	}
    	        		if (i == rightIndex) {
     	        		v = controlVertices.get(i);
     	        		renderer.setColor(selectColor);
  		            renderer.filledCircle(v.x, v.y, 8);
     	        	}
    	        	}
    	        }
            }
    	}
    }
}
 
Example 20
Source File: Platform.java    From ud406 with MIT License 3 votes vote down vote up
public void render(ShapeRenderer renderer) {

        // TODO: Draw a box representing the platform
        float width = right - left;
        float height = top - bottom;

        renderer.setColor(Color.BLUE);
        renderer.rect(left, bottom, width, height);

    }