Search in sources :

Example 6 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class ViewportSample method initGame.

@Override
protected void initGame() {
    entityBuilder().view("background.png").buildAndAttach();
    var e = entityBuilder().at(150, 150).view(new Rectangle(10, 10, Color.BLUE)).with(new DeveloperWASDControl()).buildAndAttach();
    getGameScene().getViewport().setBounds(30, 30, 1600 - 30, 1200 - 30);
    getGameScene().getViewport().bindToEntity(e, getAppWidth() / 2, getAppHeight() / 2);
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl) Rectangle(javafx.scene.shape.Rectangle)

Example 7 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class PhysicsSample method initGame.

@Override
protected void initGame() {
    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();
}
Also used : DeveloperWASDControl(dev.DeveloperWASDControl) HitBox(com.almasb.fxgl.physics.HitBox) Rectangle(javafx.scene.shape.Rectangle)

Example 8 with DeveloperWASDControl

use of dev.DeveloperWASDControl in project FXGL by AlmasB.

the class TimeGameApp method initGame.

@Override
protected void initGame() {
    getGameScene().setBackgroundColor(Color.BLACK);
    player = spawnRect(Point2D.ZERO);
    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