use of com.badlogic.gdx.math.Rectangle in project commons-gdx by gemserk.
the class TextButton method recalculateBoundsSize.
private void recalculateBoundsSize(CharSequence text) {
Rectangle textBounds = SpriteBatchUtils.getBounds(font, text, getX(), getY());
width = textBounds.getWidth();
height = textBounds.getHeight();
}
use of com.badlogic.gdx.math.Rectangle in project Entitas-Java by Rubentxu.
the class PongState method initialize.
@Override
public void initialize() {
// Input
Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
context.core.createEntity().addBall(false).addView(new Circle(0, 0, 8)).addMotion(MathUtils.clamp(1, 230, 300), 300);
context.core.createEntity().addPlayer(Player.ID.PLAYER1).addScore("Player 1: ", 180, 470).addView(new Rectangle(-350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT)).addMotion(0, 0);
context.core.createEntity().addPlayer(Player.ID.PLAYER2).addScore("Player 2: ", 480, 470).addView(new Rectangle(350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT)).addMotion(0, 0);
systems.add(new InputSystem(context.core)).add(new ContactSystem(context.core)).add(new BoundsSystem(context.core)).add(new MoveSystem(context.core)).add(new RendererSystem(context.core, engine.sr, camera, batch, font));
}
use of com.badlogic.gdx.math.Rectangle in project Entitas-Java by Rubentxu.
the class RendererSystem method render.
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam.update();
sr.setProjectionMatrix(cam.combined);
sr.begin(ShapeRenderer.ShapeType.Filled);
sr.setColor(Color.WHITE);
for (CoreEntity e : _group.getEntities()) {
View view = e.getView();
System.out.printf("..views");
if (view.shape instanceof Rectangle) {
Rectangle ret = (Rectangle) view.shape;
sr.rect(ret.x, ret.y, ret.width, ret.height);
} else {
Circle circle = (Circle) view.shape;
sr.circle(circle.x, circle.y, circle.radius);
}
}
sr.end();
batch.begin();
for (CoreEntity e : _groupScore.getEntities()) {
Score score = e.getScore();
font.draw(batch, score.text + " " + score.points, score.x, score.y);
}
for (CoreEntity e : _groupTextureView.getEntities()) {
TextureView textureView = e.getTextureView();
batch.draw(textureView.texture, textureView.position.x, textureView.position.y, 0, 0, textureView.width, textureView.height, 1, 1, textureView.rotation);
}
batch.end();
}
use of com.badlogic.gdx.math.Rectangle in project AmazingMaze by TheVirtualMachine.
the class Player method handleDeath.
/** Handle the player dying. */
private void handleDeath() {
Rectangle thisBox = getBoundingRectangle();
for (Rectangle wire : maze.wireBoxes) {
if (thisBox.overlaps(wire)) {
if (lives <= 0) {
dead = true;
return;
}
if (!maze.help) {
lives--;
}
maze.updateLives((int) ((getX() - MapFactory.START_DISTANCE + 1) / MapFactory.WIRE_DISTANCE));
setPosition(0, maze.mapHeight / 2);
break;
}
}
}
use of com.badlogic.gdx.math.Rectangle in project Alkahest-Coffee by AlkahestDev.
the class ClientGameInstance method draw.
public void draw(SpriteBatch batch, ShapeRenderer renderer) {
batch.begin();
for (PlayerSoldier p : playWorld.getPlayers().values()) {
//DrawTools.rec(renderer,p.getRect());
p.draw(batch, playWorld.getPlayers().get(gameClient.getConnectionID()).equals(p));
}
//batch.draw(playWorld.getMap().getVisualComponent(),0,0);
batch.end();
playWorld.getMap().draw(batch);
renderer.begin(ShapeRenderer.ShapeType.Filled);
for (PlayerSoldier playerSoldier : gameClient.getPlayers().values()) {
//playerSoldier.getMouseAngle());
System.out.println(playerSoldier.getX() - playerSoldier.getCenterX());
renderer.setColor(Color.RED);
renderer.line(playerSoldier.getCenterX(), playerSoldier.getCenterY(), playerSoldier.getCenterX() + (5 * (float) Math.cos(Math.toRadians(playerSoldier.getMouseAngle()))), playerSoldier.getCenterY() + (5 * (float) Math.sin(Math.toRadians(playerSoldier.getMouseAngle()))));
renderer.setColor(Color.BLUE);
DrawTools.rec(renderer, new Rectangle((int) (playerSoldier.getX()), (int) (playerSoldier.getY() + playerSoldier.getvY()), 1, 1));
}
renderer.end();
}
Aggregations