use of com.almasb.fxgl.dsl.components.RandomMoveComponent 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();
}
use of com.almasb.fxgl.dsl.components.RandomMoveComponent in project FXGL by AlmasB.
the class BenchmarkSample method initGame.
@Override
protected void initGame() {
frames = 0;
components = new Component[NUM_OBJECTS];
textures = new Texture[NUM_OBJECTS];
getGameWorld().addEntityFactory(new BenchmarkFactory());
for (int i = 0; i < NUM_OBJECTS; i++) {
if (IS_JAVAFX) {
var t = texture("ball.png", 100, 100);
textures[i] = t;
addUINode(t, random(100, 500), random(100, 500));
} else {
var e = spawn("ball");
e.setUpdateEnabled(false);
// var c = new ProjectileComponent(new Point2D(random(0.0, 1.0), random(0.0, 1.0)), FXGLMath.map(i, 0, 2000, 10, 60));
var c = new RandomMoveComponent(new Rectangle2D(0, 0, getAppWidth(), getAppHeight()), random(10, 400));
components[i] = c;
ComponentHelper.setEntity(c, e);
}
}
}
Aggregations