use of com.almasb.fxgl.app.scene.GameView in project FXGL by AlmasB.
the class RaycastSample method initGame.
@Override
protected void initGame() {
spawnWall(500, 100, 50, 50);
spawnWall(550, 150, 50, 50);
spawnWall(600, 200, 50, 50);
spawnWall(600, 400, 50, 50);
spawnWall(300, 450, 50, 50);
spawnWall(500, 550, 50, 50);
spawnWall(300, 300, 50, 50);
laser = new Line();
laser.setStroke(Color.RED);
laser.setStrokeWidth(2);
laser.setStartY(300);
getGameScene().addGameView(new GameView(laser, 0));
endY = -300;
}
use of com.almasb.fxgl.app.scene.GameView in project FXGL by AlmasB.
the class MapGenerationSample method coloredMap.
private void coloredMap() {
// tile size
int size = 1;
int W = (getAppWidth() + 200) / size;
int H = (getAppHeight() + 200) / size;
Grid<HeightMapGenerator.HeightData> map = new Grid<>(HeightMapGenerator.HeightData.class, W, H, new CustomHeightMapGenerator(W, H));
AnimatedColor water = new AnimatedColor(Color.DARKBLUE, Color.AQUA);
AnimatedColor land = new AnimatedColor(Color.DARKGREEN, Color.LIGHTGREEN);
AnimatedColor desert = new AnimatedColor(Color.GREENYELLOW, Color.LIGHTYELLOW);
AnimatedColor snow = new AnimatedColor(Color.GREEN, Color.WHITESMOKE);
WritableImage image = new WritableImage(W, H);
map.forEach(cell -> {
AnimatedColor anim;
double adjustedValue;
if (cell.getHeight() < 0.2) {
anim = water;
adjustedValue = map(cell.getHeight(), 0.0, 0.2, 0.0, 1.0);
} else if (cell.getHeight() < 0.4) {
anim = land;
adjustedValue = map(cell.getHeight(), 0.2, 0.4, 0.0, 1.0);
} else if (cell.getHeight() < 0.9) {
anim = desert;
adjustedValue = map(cell.getHeight(), 0.4, 0.9, 0.0, 1.0);
} else {
anim = snow;
adjustedValue = map(cell.getHeight(), 0.9, 1.0, 0.0, 1.0);
}
image.getPixelWriter().setColor(cell.getX(), cell.getY(), anim.getValue(adjustedValue, interpolator.EASE_OUT()));
});
getGameScene().getViewport().bindToEntity(new Entity(), 0, 0);
var t = new Texture(image);
t.setTranslateX(-100);
t.setTranslateY(-100);
getGameScene().addGameView(new GameView(t, 0));
}
use of com.almasb.fxgl.app.scene.GameView in project FXGL by AlmasB.
the class Anim3DSample method initGame.
@Override
protected void initGame() {
var box = new Box();
box.setMaterial(new PhongMaterial(Color.BLUE));
var e = FXGL.entityBuilder().at(-3, 0, 0).view(box).buildAndAttach();
FXGL.animationBuilder().repeatInfinitely().autoReverse(true).rotate(e).from(new Point3D(0, 0, 0)).to(new Point3D(45, 45, 45)).buildAndPlay();
var box2 = new Box();
box2.setMaterial(new PhongMaterial(Color.RED));
FXGL.getGameScene().addGameView(new GameView(box2, 0));
FXGL.animationBuilder().repeatInfinitely().autoReverse(true).rotate(box2).from(new Point3D(0, 0, 0)).to(new Point3D(45, 45, 45)).buildAndPlay();
}
Aggregations