Search in sources :

Example 1 with Score

use of com.ilargia.games.logicbrick.component.Score 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();
}
Also used : CoreEntity(com.ilargia.games.entitas.core.CoreEntity) Circle(com.badlogic.gdx.math.Circle) Score(com.ilargia.games.logicbrick.component.Score) Rectangle(com.badlogic.gdx.math.Rectangle) TextureView(com.ilargia.games.logicbrick.component.TextureView) TextureView(com.ilargia.games.logicbrick.component.TextureView) View(com.ilargia.games.logicbrick.component.View)

Example 2 with Score

use of com.ilargia.games.logicbrick.component.Score in project Entitas-Java by Rubentxu.

the class BoundsSystem method execute.

@Override
public void execute(float deltatime) {
    CoreEntity ball = _context.getBallEntity();
    Circle ballShape = (Circle) ball.getView().shape;
    Motion motion = ball.getMotion();
    for (CoreEntity e : _groupPlayer.getEntities()) {
        Player player = e.getPlayer();
        Score score = e.getScore();
        if (ballShape.x + ballShape.radius <= -(WIDTH / 2) && player.id == Player.ID.PLAYER2)
            restart(ballShape, motion, score);
        if (ballShape.x - ballShape.radius >= (WIDTH / 2) && player.id == Player.ID.PLAYER1)
            restart(ballShape, motion, score);
    }
}
Also used : CoreEntity(com.ilargia.games.entitas.core.CoreEntity) Circle(com.badlogic.gdx.math.Circle) Motion(com.ilargia.games.logicbrick.component.Motion) Player(com.ilargia.games.logicbrick.component.Player) Score(com.ilargia.games.logicbrick.component.Score)

Example 3 with Score

use of com.ilargia.games.logicbrick.component.Score in project Entitas-Java by Rubentxu.

the class CoreEntity method replaceScore.

public CoreEntity replaceScore(String text, int x, int y) {
    Score component = (Score) recoverComponent(CoreComponentsLookup.Score);
    if (component == null) {
        component = new Score(text, x, y);
    } else {
        component.text = text;
        ;
        component.x = x;
        ;
        component.y = y;
        ;
        component.points = 0;
    }
    replaceComponent(CoreComponentsLookup.Score, component);
    return this;
}
Also used : Score(com.ilargia.games.logicbrick.component.Score)

Example 4 with Score

use of com.ilargia.games.logicbrick.component.Score in project Entitas-Java by Rubentxu.

the class CoreEntity method addScore.

public CoreEntity addScore(String text, int x, int y) {
    Score component = (Score) recoverComponent(CoreComponentsLookup.Score);
    if (component == null) {
        component = new Score(text, x, y);
    } else {
        component.text = text;
        ;
        component.x = x;
        ;
        component.y = y;
        ;
        component.points = 0;
    }
    addComponent(CoreComponentsLookup.Score, component);
    return this;
}
Also used : Score(com.ilargia.games.logicbrick.component.Score)

Aggregations

Score (com.ilargia.games.logicbrick.component.Score)4 Circle (com.badlogic.gdx.math.Circle)2 CoreEntity (com.ilargia.games.entitas.core.CoreEntity)2 Rectangle (com.badlogic.gdx.math.Rectangle)1 Motion (com.ilargia.games.logicbrick.component.Motion)1 Player (com.ilargia.games.logicbrick.component.Player)1 TextureView (com.ilargia.games.logicbrick.component.TextureView)1 View (com.ilargia.games.logicbrick.component.View)1