use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class FiringRangeFactory method newBullet.
@Spawns("bullet")
public Entity newBullet(SpawnData data) {
var sphere = new Sphere(0.5);
sphere.setMaterial(new PhongMaterial(Color.YELLOW));
Point3D dir = data.get("dir");
return entityBuilder(data).type(FiringRangeEntityType.BULLET).bbox(new HitBox(BoundingShape.box3D(1, 1, 1))).view(sphere).with(new Projectile3DComponent(dir, 50)).with(new ExpireCleanComponent(Duration.seconds(5))).collidable().build();
}
use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class SnakeFactory method newPlayer.
@Spawns("player")
public Entity newPlayer(SpawnData data) {
Box box = new Box(1, 1, 1);
box.setMaterial(new PhongMaterial(Color.BLUE));
return entityBuilder(data).type(SnakeApp.SnakeType.SNAKE).bbox(new HitBox(BoundingShape.box3D(1, 1, 1))).view(box).collidable().with(new SnakeComponent()).build();
}
use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class SnakeFactory method newFood.
@Spawns("food")
public Entity newFood(SpawnData data) {
Box box = new Box(1, 1, 1);
box.setMaterial(new PhongMaterial(Color.YELLOW));
return entityBuilder(data).type(SnakeApp.SnakeType.FOOD).bbox(new HitBox(BoundingShape.box3D(1, 1, 1))).view(box).collidable().build();
}
use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class RobotFactory method newRobot.
@Spawns("robot")
public Entity newRobot(SpawnData data) {
BodyDef bd = new BodyDef();
bd.setFixedRotation(true);
bd.setType(BodyType.DYNAMIC);
PhysicsComponent physics = new PhysicsComponent();
// friction 0 to avoid sticking to walls
physics.setFixtureDef(new FixtureDef().friction(0).density(0.25f));
physics.setBodyDef(bd);
physics.addGroundSensor(new HitBox("GROUND_SENSOR", new Point2D(275 / 2 - 3, 260 - 5), BoundingShape.box(6, 10)));
return entityBuilder(data).from(data).bbox(new HitBox("head", new Point2D(110, 50), BoundingShape.box(70, 70))).bbox(new HitBox("body", new Point2D(110, 120), BoundingShape.box(40, 130))).bbox(new HitBox("legs", new Point2D(275 / 2 - 25, 125 * 2), BoundingShape.box(40, 10))).scaleOrigin(275 / 2, 125 * 2).collidable().with(new StateComponent()).with(physics).with(new RobotComponent()).build();
}
use of com.almasb.fxgl.entity.Spawns in project FXGL by AlmasB.
the class CircleNNFactory method newBullet.
@Spawns("bullet")
public Entity newBullet(SpawnData data) {
Point2D dir = data.get("dir");
var view = new Rectangle(30, 2, Color.WHITE);
view.setArcWidth(15);
view.setArcHeight(15);
return entityBuilder(data).type(BULLET).viewWithBBox(view).collidable().with(new ProjectileComponent(dir, 800)).with(new OffscreenCleanComponent()).with("damage", data.hasKey("damage") ? data.get("damage") : 1).build();
}
Aggregations