Search in sources :

Example 1 with Player

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

the class InputSystem method execute.

@Override
public void execute(float deltatime) {
    for (CoreEntity e : _group.getEntities()) {
        Motion motion = e.getMotion();
        Player player = e.getPlayer();
        View view = e.getView();
        if (player.id == Player.ID.PLAYER1) {
            motion.velocity.y = 0;
            if (movesUp(Input.Keys.W, (Rectangle) view.shape)) {
                motion.velocity.y = Pong.PLAYER_SPEED;
            }
            if (movesDown(Input.Keys.S, (Rectangle) view.shape)) {
                motion.velocity.y = -Pong.PLAYER_SPEED;
            }
        }
        if (player.id == Player.ID.PLAYER2) {
            motion.velocity.y = 0;
            if (movesUp(Input.Keys.UP, (Rectangle) view.shape)) {
                motion.velocity.y = Pong.PLAYER_SPEED;
            }
            if (movesDown(Input.Keys.DOWN, (Rectangle) view.shape)) {
                motion.velocity.y = -Pong.PLAYER_SPEED;
            }
        }
    }
}
Also used : CoreEntity(com.ilargia.games.entitas.core.CoreEntity) Motion(com.ilargia.games.logicbrick.component.Motion) Player(com.ilargia.games.logicbrick.component.Player) View(com.ilargia.games.logicbrick.component.View)

Example 2 with Player

use of com.ilargia.games.logicbrick.component.Player 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 Player

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

the class CoreEntity method addPlayer.

public CoreEntity addPlayer(Player.ID id) {
    Player component = (Player) recoverComponent(CoreComponentsLookup.Player);
    if (component == null) {
        component = new Player();
    }
    component.id = id;
    addComponent(CoreComponentsLookup.Player, component);
    return this;
}
Also used : Player(com.ilargia.games.logicbrick.component.Player)

Example 4 with Player

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

the class CoreEntity method replacePlayer.

public CoreEntity replacePlayer(Player.ID id) {
    Player component = (Player) recoverComponent(CoreComponentsLookup.Player);
    if (component == null) {
        component = new Player();
    }
    component.id = id;
    replaceComponent(CoreComponentsLookup.Player, component);
    return this;
}
Also used : Player(com.ilargia.games.logicbrick.component.Player)

Aggregations

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