use of common.PlayerControl in project FXGL by AlmasB.
the class PhysicsSample method initGame.
@Override
protected void initGame() {
playerControl = new PlayerControl();
player = Entities.builder().type(Type.PLAYER).at(100, 100).bbox(new HitBox("PLAYER_BODY", BoundingShape.box(40, 40))).viewFromNode(new Rectangle(40, 40, Color.BLUE)).with(playerControl).build();
enemy = Entities.builder().type(Type.ENEMY).at(200, 100).viewFromNodeWithBBox(new Rectangle(40, 40, Color.RED)).build();
// 2. we need to add Collidable component and set its value to true
// so that collision system can 'see' our entities
player.addComponent(new CollidableComponent(true));
enemy.addComponent(new CollidableComponent(true));
getGameWorld().addEntities(player, enemy);
}
use of common.PlayerControl in project FXGL by AlmasB.
the class PhysicsSample2 method initGame.
@Override
protected void initGame() {
playerControl = new PlayerControl();
player = Entities.builder().type(Type.PLAYER).at(100, 100).bbox(new HitBox("PLAYER_BODY", BoundingShape.box(250, 40))).viewFromNode(new Rectangle(250, 40, Color.BLUE)).with(playerControl).build();
enemy = Entities.builder().type(Type.ENEMY).at(200, 100).viewFromNodeWithBBox(new Rectangle(40, 40, Color.RED)).build();
// 2. we need to add Collidable component and set its value to true
// so that collision system can 'see' our entities
player.addComponent(new CollidableComponent(true));
enemy.addComponent(new CollidableComponent(true));
getGameWorld().addEntities(player, enemy);
}
use of common.PlayerControl in project FXGL by AlmasB.
the class SaveSample method initGame.
private void initGame(Point2D playerPos, Point2D enemyPos) {
playerPosition = playerPos;
enemyPosition = enemyPos;
player = new Entity();
player.getTypeComponent().setValue(Type.PLAYER);
player.getPositionComponent().setValue(playerPosition);
player.getViewComponent().setView(new EntityView(new Rectangle(40, 40, Color.BLUE)));
playerControl = new PlayerControl();
player.addControl(playerControl);
enemy = new Entity();
enemy.getTypeComponent().setValue(Type.ENEMY);
enemy.getPositionComponent().setValue(enemyPosition);
enemy.getViewComponent().setView(new EntityView(new Rectangle(40, 40, Color.RED)));
getGameWorld().addEntities(player, enemy);
}
use of common.PlayerControl in project FXGL by AlmasB.
the class AchievementsSample method initGame.
@Override
protected void initGame() {
playerControl = new PlayerControl();
Entity player = Entities.builder().at(100, 100).viewFromNode(new Rectangle(40, 40)).with(playerControl).buildAndAttach(getGameWorld());
getGameState().doubleProperty("playerX").bind(player.getPositionComponent().xProperty());
}
use of common.PlayerControl in project FXGL by AlmasB.
the class BehaviorSample method initGame.
@Override
protected void initGame() {
player = Entities.builder().at(100, 100).viewFromNode(new Rectangle(40, 40)).with(new PlayerControl()).buildAndAttach(getGameWorld());
playerControl = player.getControl(PlayerControl.class);
Entities.builder().at(400, 100).viewFromNode(new Rectangle(40, 40, Color.RED)).with(new AIControl("patrol.tree")).buildAndAttach(getGameWorld());
Entities.builder().at(600, 100).viewFromNode(new Rectangle(40, 40, Color.LIGHTGOLDENRODYELLOW)).with(new AIControl("patrol.tree")).buildAndAttach(getGameWorld());
}
Aggregations