add small example

This commit is contained in:
2025-04-27 20:18:31 +02:00
parent cbbce43ede
commit b57fa1482b

View File

@@ -39,12 +39,19 @@ public class DDDView extends GameAdaptator {
// Invoked when a cell is hovered
private void onCellEnter(Coordinate coordinate) {
System.out.println("Enter : " + coordinate);
// small test turning a piece red when hovered
Piece p = pieceAt(coordinate);
if (p == null)
return;
this.world.getEntity(p).setColor(new Vector3f(1, 0, 0));
}
// Invoked when a cell is not hovered anymore
private void onCellExit(Coordinate coordinate) {
System.out.println("Exit : " + coordinate);
Piece p = pieceAt(coordinate);
if (p == null)
return;
this.world.getEntity(p).setColor(p.getColor() == Color.White ? WHITE : BLACK);
}
private Piece pieceAt(Coordinate pos) {
@@ -79,11 +86,11 @@ public class DDDView extends GameAdaptator {
}
public void run() {
this.window.addRegularTask((delta) -> {
final float angle = 1f;
final Camera cam = this.world.getCamera();
cam.setRotateAngle(cam.getRotateAngle() + angle * delta);
});
// this.window.addRegularTask((delta) -> {
// final float angle = 1f;
// final Camera cam = this.world.getCamera();
// cam.setRotateAngle(cam.getRotateAngle() + angle * delta);
// });
this.window.run();
}