use of com.almasb.fxgl.devtools.DeveloperWASDControl in project FXGL by AlmasB.
the class ScriptSample method initGame.
@Override
protected void initGame() {
Entity e = Entities.builder().type(EntityType.PC).at(300, 300).viewFromNodeWithBBox(new Rectangle(40, 40, Color.BLUE)).with(new CollidableComponent(true)).with(new DeveloperWASDControl()).buildAndAttach(getGameWorld());
Entities.builder().type(EntityType.NPC).at(400, 300).viewFromNodeWithBBox(new Rectangle(40, 40, Color.RED)).with(new CollidableComponent(true)).buildAndAttach(getGameWorld());
for (int i = 0; i < 3; i++) {
Entities.builder().type(EntityType.COIN).at(FXGLMath.random(100, 450), 500).viewFromNodeWithBBox(new Circle(20, Color.GOLD)).with(new CollidableComponent(true)).buildAndAttach(getGameWorld());
}
getMasterTimer().runAtInterval(() -> {
getAudioPlayer().playPositionalSound("drop.wav", new Point2D(400, 300), e.getCenter(), 600);
}, Duration.seconds(2));
}
use of com.almasb.fxgl.devtools.DeveloperWASDControl in project FXGL by AlmasB.
the class ScriptSample2 method initGame.
@Override
protected void initGame() {
Entity e = Entities.builder().type(EntityType.PC).at(300, 300).viewFromNodeWithBBox(new Rectangle(40, 40, Color.BLUE)).with(new CollidableComponent(true)).with(new DeveloperWASDControl()).buildAndAttach(getGameWorld());
Entities.builder().type(EntityType.NPC).at(400, 300).viewFromNodeWithBBox(new Rectangle(40, 40, Color.RED)).with(new CollidableComponent(true)).buildAndAttach(getGameWorld());
}
use of com.almasb.fxgl.devtools.DeveloperWASDControl in project FXGL by AlmasB.
the class StateSample method initGame.
@Override
protected void initGame() {
shopState = new ShopState();
player = Entities.builder().type(Type.PLAYER).at(100, 100).viewFromNode(new Rectangle(40, 40)).with(new DeveloperWASDControl()).buildAndAttach(getGameWorld());
}
use of com.almasb.fxgl.devtools.DeveloperWASDControl in project FXGL by AlmasB.
the class ScriptSample method initGame.
@Override
protected void initGame() {
player = Entities.builder().at(100, 100).viewFromNodeWithBBox(new Rectangle(40, 40, Color.BLUE)).with(new DeveloperWASDControl()).buildAndAttach(getGameWorld());
enemy = Entities.builder().at(180, 100).viewFromNodeWithBBox(new Rectangle(30, 30, Color.RED)).with(new AliveComponent(true)).with(new ActivatorComponent(), new IDComponent("wanderer", 0)).with("onActivate", "first_script.js").with("onActivate.name", "wanderer").with("onActivate.id", 0).with("onDeath", "second_script.js").with("onRevive", "first_script.js").buildAndAttach(getGameWorld());
Entities.builder().at(380, 100).viewFromNodeWithBBox(new Rectangle(30, 30, Color.RED)).with(new AliveComponent(true)).with(new ActivatorComponent(), new IDComponent("wanderer", 1)).with("onActivate", "second_script.js").with("onActivate.name", "wanderer").with("onActivate.id", 1).buildAndAttach(getGameWorld());
}
Aggregations