use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class CircleNNFactory method newCircle.
@Spawns("circle")
public Entity newCircle(SpawnData data) {
var circleComponent = new CircleComponent();
var color = FXGLMath.randomColor().brighter();
var view = new Circle(32, 32, 30, null);
view.setStrokeWidth(2);
view.setStroke(color);
var hp = new HealthIntComponent(49);
var viewHP = new Circle(32, 32, 30);
viewHP.radiusProperty().bind(hp.valueProperty().divide(49.0).multiply(30));
var viewRank = getUIFactoryService().newText("", Color.MIDNIGHTBLUE, 12.0);
viewRank.setTranslateX(32);
viewRank.setTranslateY(32);
var e = entityBuilder(data).type(CIRCLE).bbox(new HitBox(BoundingShape.box(64, 64))).view(view).view(viewHP).collidable().with("isShielded", false).with("rank", 1).with(new TimeComponent()).with(new EffectComponent()).with(hp).with(new RandomMoveComponent(new Rectangle2D(0, 0, getAppWidth(), getAppHeight()), 300)).with(circleComponent).with(new BlockCollisionComponent()).build();
viewHP.fillProperty().bind(Bindings.when(e.getProperties().booleanProperty("isShielded")).then(Color.WHITE).otherwise(Color.color(0.5, 0.78, 0.2, 0.5).brighter()));
viewRank.textProperty().bind(e.getProperties().intProperty("rank").asString());
return e;
}
use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class FiringRangeFactory method newLevelBox.
@Spawns("levelBox")
public Entity newLevelBox(SpawnData data) {
var ground = new Box(50, 0.5, 150);
ground.setMaterial(new PhongMaterial(Color.BROWN));
var WALL_HEIGHT = 20;
var wallL = new Box(0.5, WALL_HEIGHT, 150);
wallL.setMaterial(new PhongMaterial(Color.LIGHTCORAL));
wallL.setTranslateY(-WALL_HEIGHT / 2.0);
wallL.setTranslateX(-ground.getWidth() / 2.0);
var wallR = new Box(0.5, WALL_HEIGHT, 150);
wallR.setMaterial(new PhongMaterial(Color.LIGHTCORAL));
wallR.setTranslateY(-WALL_HEIGHT / 2.0);
wallR.setTranslateX(+ground.getWidth() / 2.0);
var wallT = new Box(50, WALL_HEIGHT, 0.5);
wallT.setMaterial(new PhongMaterial(Color.LIGHTCORAL));
wallT.setTranslateY(-WALL_HEIGHT / 2.0);
wallT.setTranslateZ(+wallL.getDepth() / 2.0);
var wallB = new Box(50, WALL_HEIGHT, 0.5);
wallB.setMaterial(new PhongMaterial(Color.LIGHTCORAL));
wallB.setTranslateY(-WALL_HEIGHT / 2.0);
wallB.setTranslateZ(-25);
return entityBuilder(data).view(new Group(ground, wallL, wallR, wallT, wallB)).build();
}
use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class FiringRangeFactory method newTarget.
@Spawns("target")
public Entity newTarget(SpawnData data) {
var box = new Box(5, 5, 0.2);
box.setMaterial(new PhongMaterial(Color.DARKKHAKI));
var e = entityBuilder(data).type(FiringRangeEntityType.TARGET).bbox(new HitBox(BoundingShape.box3D(5, 5, 0.2))).view(box).collidable().with(new Projectile3DComponent(new Point3D(1, 0, 0), 15)).with(new ExpireCleanComponent(Duration.seconds(6))).build();
animationBuilder().duration(Duration.seconds(0.6)).interpolator(Interpolators.ELASTIC.EASE_OUT()).scale(e).from(new Point3D(0, 0, 0)).to(new Point3D(1, 1, 1)).buildAndPlay();
return e;
}
Aggregations