aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

This commit is contained in:
2025-04-25 17:03:28 +02:00
parent 098b605799
commit cff2d92070
7 changed files with 159 additions and 22 deletions

View File

@@ -1,10 +1,16 @@
package chess.view.DDDrender;
import org.joml.Vector3f;
import org.lwjgl.*;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import org.lwjgl.system.*;
import chess.controller.CommandExecutor;
import chess.controller.commands.GetPieceAtCommand;
import chess.model.Coordinate;
import chess.model.Piece;
import java.io.IOException;
import java.nio.*;
@@ -21,14 +27,12 @@ public class Window {
private Renderer renderer;
private Camera cam;
private final CommandExecutor commandExecutor;
public Window() {
public Window(CommandExecutor commandExecutor, Renderer renderer) {
this.renderer = new Renderer();
this.cam = new Camera();
}
public static void main(String[] args) {
new Window().run();
this.commandExecutor = commandExecutor;
}
public void run() {
@@ -93,8 +97,31 @@ public class Window {
}
private void render() {
cam.move(0.001f, 0.001f);
final float angle = 0.01f;
float x = cam.getPos().x();
float y = cam.getPos().z();
cam.setPosition(new Vector3f(x * (float) Math.cos(angle) - y * (float) Math.sin(angle), 1.0f,
x * (float) Math.sin(angle) + y * (float) Math.cos(angle)));
renderer.Render(cam);
renderPieces();
}
private Piece pieceAt(Coordinate pos) {
GetPieceAtCommand cmd = new GetPieceAtCommand(pos);
this.commandExecutor.executeCommand(cmd);
return cmd.getPiece();
}
private void renderPieces() {
for (int i = 0; i < Coordinate.VALUE_MAX; i++) {
for (int j = 0; j < Coordinate.VALUE_MAX; j++) {
Coordinate pos = new Coordinate(i, j);
Piece piece = pieceAt(pos);
if (piece == null)
continue;
this.renderer.RenderPiece(pieceAt(pos), pos);
}
}
}
private void loop() {