use of com.almasb.fxgl.input.InputCapture in project FXGL by AlmasB.
the class CircleNNApp method initGame.
@Override
protected void initGame() {
getGameWorld().addEntityFactory(new CircleNNFactory());
getGameScene().setBackgroundColor(Color.BLACK);
spawn("block", 200, 200);
spawn("block", getAppWidth() - 200 - 64, 200);
spawn("block", 200, getAppHeight() - 200 - 64);
spawn("block", getAppWidth() - 200 - 64, getAppHeight() - 200 - 64);
var spawnPoints = List.of(new Point2D(100, 100), new Point2D(getAppWidth() - 100 - 64, 100), new Point2D(getAppWidth() / 2.0 - 32, 100), new Point2D(100, getAppHeight() / 2.0 - 32), new Point2D(getAppWidth() - 100 - 64, getAppHeight() / 2.0 - 32), new Point2D(getAppWidth() / 2.0 - 32, getAppHeight() / 2.0 - 32), new Point2D(100, getAppHeight() - 100 - 64), new Point2D(getAppWidth() - 100 - 64, getAppHeight() - 100 - 64), new Point2D(getAppWidth() / 2.0 - 32, getAppHeight() - 100 - 64));
spawn("circle", 500.0, 600.0);
spawn("circle", 500.0, 600.0);
// spawnPoints.forEach(point -> {
// for (int i = 0; i < 11; i++) {
// spawn("circle", point);
// }
// });
player = getGameWorld().getRandom(CIRCLE).get();
player.removeComponent(RandomMoveComponent.class);
player.removeComponent(BlockCollisionComponent.class);
player.addComponent(new KeepOnScreenComponent());
player.addComponent(new PlayerComponent());
getGameWorld().getEntitiesByType(CIRCLE).stream().filter(e -> e != player).forEach(e -> {
e.getComponent(RandomMoveComponent.class).pause();
e.getComponent(BlockCollisionComponent.class).pause();
Bundle bundle = getFileSystemService().<Bundle>readDataTask("editor_json/input/input0.dat").run();
var input = new InputCapture();
input.read(bundle);
e.getComponent(CircleComponent.class).getInput().applyCapture(input);
});
place = getGameWorld().getEntitiesByType(CIRCLE).size();
run(() -> {
var powerupType = PowerupType.SHIELD;
// var powerupType = FXGLMath.random(PowerupType.values()).get();
spawn("powerup", new SpawnData(FXGLMath.randomPoint(new Rectangle2D(0, 0, getAppWidth(), getAppHeight()))).put("powerupType", powerupType));
}, Duration.seconds(3));
capture = getInput().startCapture();
}
Aggregations