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;
}
}
}
}
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);
}
}
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;
}
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;
}
Aggregations