Search in sources :

Example 1 with DeveloperWASDControl

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));
}
Also used : DeveloperWASDControl(com.almasb.fxgl.devtools.DeveloperWASDControl) Entity(com.almasb.fxgl.entity.Entity) Circle(javafx.scene.shape.Circle) Point2D(javafx.geometry.Point2D) CollidableComponent(com.almasb.fxgl.entity.component.CollidableComponent) Rectangle(javafx.scene.shape.Rectangle)

Example 2 with DeveloperWASDControl

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());
}
Also used : DeveloperWASDControl(com.almasb.fxgl.devtools.DeveloperWASDControl) Entity(com.almasb.fxgl.entity.Entity) CollidableComponent(com.almasb.fxgl.entity.component.CollidableComponent) Rectangle(javafx.scene.shape.Rectangle)

Example 3 with DeveloperWASDControl

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());
}
Also used : DeveloperWASDControl(com.almasb.fxgl.devtools.DeveloperWASDControl) Rectangle(javafx.scene.shape.Rectangle)

Example 4 with DeveloperWASDControl

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());
}
Also used : DeveloperWASDControl(com.almasb.fxgl.devtools.DeveloperWASDControl) Rectangle(javafx.scene.shape.Rectangle) ActivatorComponent(com.almasb.fxgl.entity.component.ActivatorComponent) IDComponent(com.almasb.fxgl.entity.component.IDComponent) AliveComponent(com.almasb.fxgl.entity.component.AliveComponent)

Aggregations

DeveloperWASDControl (com.almasb.fxgl.devtools.DeveloperWASDControl)4 Rectangle (javafx.scene.shape.Rectangle)4 Entity (com.almasb.fxgl.entity.Entity)2 CollidableComponent (com.almasb.fxgl.entity.component.CollidableComponent)2 ActivatorComponent (com.almasb.fxgl.entity.component.ActivatorComponent)1 AliveComponent (com.almasb.fxgl.entity.component.AliveComponent)1 IDComponent (com.almasb.fxgl.entity.component.IDComponent)1 Point2D (javafx.geometry.Point2D)1 Circle (javafx.scene.shape.Circle)1