Search in sources :

Example 1 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class ShopSample method initGame.

@Override
protected void initGame() {
    shopState = new ShopState();
    player = entityBuilder().type(Type.PLAYER).at(100, 100).view(new Rectangle(40, 40)).with(new DeveloperWASDControl()).buildAndAttach();
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl) Rectangle(javafx.scene.shape.Rectangle)

Example 2 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class ManualResizeSample method initGame.

@Override
protected void initGame() {
    entityBuilder().view(new Rectangle(100.0, 100.0, Color.GREEN)).with(new DeveloperWASDControl()).buildAndAttach();
    addUINode(new Rectangle(getAppWidth(), getAppHeight(), new Color(.0, .0, 1.0, .5)));
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl) Color(javafx.scene.paint.Color) Rectangle(javafx.scene.shape.Rectangle)

Example 3 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class BBoxSample method initGame.

@Override
protected void initGame() {
    // entity 1
    player = entityBuilder().type(Type.PLAYER).at(100, 150).viewWithBBox("brick.png").with(new CollidableComponent(true), new DeveloperWASDControl()).with(new RandomMoveComponent(new Rectangle2D(0, 0, getAppWidth(), getAppHeight()), 500)).with(new EffectComponent()).with(new TimeComponent(1.0)).zIndex(250).buildAndAttach();
    player.getTransformComponent().setRotationOrigin(new Point2D(64, 64));
    player.getTransformComponent().scaleOriginXProperty().setValue(64);
    player.getTransformComponent().scaleOriginYProperty().setValue(64);
    // entity 2
    entityBuilder().at(100, 100).viewWithBBox(new Rectangle(40, 40, Color.RED)).with(new CollidableComponent(true)).with(new LiftComponent().yAxisSpeedDuration(150, Duration.seconds(3)).xAxisSpeedDuration(100, Duration.seconds(3))).with(new EffectComponent()).zIndex(250).buildAndAttach();
    // entity 3
    entityBuilder().type(Type.NPC).at(400, 150).bbox(new HitBox(new Point2D(5, 5), BoundingShape.circle(20))).view(texture("enemy1.png").toAnimatedTexture(2, Duration.seconds(1)).loop()).with(new EffectComponent()).buildAndAttach();
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl) RandomMoveComponent(com.almasb.fxgl.dsl.components.RandomMoveComponent) HitBox(com.almasb.fxgl.physics.HitBox) TimeComponent(com.almasb.fxgl.entity.components.TimeComponent) Point2D(javafx.geometry.Point2D) CollidableComponent(com.almasb.fxgl.entity.components.CollidableComponent) Rectangle2D(javafx.geometry.Rectangle2D) Rectangle(javafx.scene.shape.Rectangle) LiftComponent(com.almasb.fxgl.dsl.components.LiftComponent) EffectComponent(com.almasb.fxgl.dsl.components.EffectComponent)

Example 4 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class PhysicsCollisionSample method initGame.

@Override
protected void initGame() {
    this.player = FXGL.entityBuilder().type(Type.PLAYER).at(100, 100).bbox(new HitBox(BoundingShape.box(40, 40))).view(new Rectangle(40, 40, Color.BLUE)).collidable().with(new DeveloperWASDControl()).buildAndAttach();
    FXGL.entityBuilder().type(Type.ENEMY).at(200, 100).viewWithBBox(new Rectangle(40, 40, Color.RED)).collidable().buildAndAttach();
    FXGL.entityBuilder().type(Type.ENEMY).at(300, 100).viewWithBBox(new Rectangle(40, 60, Color.RED)).rotate(35).collidable().buildAndAttach();
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl) HitBox(com.almasb.fxgl.physics.HitBox) Rectangle(javafx.scene.shape.Rectangle)

Example 5 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class BeatEmUpSample method initGame.

@Override
protected void initGame() {
    getGameScene().setBackgroundColor(Color.DARKGRAY);
    getGameWorld().addEntityFactory(new ZombieFactory());
    for (int i = 0; i < 5; i++) {
        var e = spawn("zombie", 600, 15 + i * 140);
        e.setScaleX(-1);
    }
    player = spawn("player", 100, 100);
    player.addComponent(new DeveloperWASDControl());
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl)

Aggregations

DeveloperWASDControl (dev.DeveloperWASDControl)8 Rectangle (javafx.scene.shape.Rectangle)6 HitBox (com.almasb.fxgl.physics.HitBox)3 EffectComponent (com.almasb.fxgl.dsl.components.EffectComponent)1 LiftComponent (com.almasb.fxgl.dsl.components.LiftComponent)1 RandomMoveComponent (com.almasb.fxgl.dsl.components.RandomMoveComponent)1 CollidableComponent (com.almasb.fxgl.entity.components.CollidableComponent)1 TimeComponent (com.almasb.fxgl.entity.components.TimeComponent)1 Point2D (javafx.geometry.Point2D)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Color (javafx.scene.paint.Color)1