From d0ba0d011f155e13f2ca68912aa303c719c2dd32 Mon Sep 17 00:00:00 2001 From: Yvonne Schmidt Date: Mon, 2 Dec 2024 07:45:37 +0100 Subject: [PATCH] added documentation for CameraController --- .../monopoly/client/gui/CameraController.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java index 61fe44c..718d871 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/CameraController.java @@ -4,20 +4,16 @@ import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; /** - * Steuert die Kamerabewegung in der Szene. + * Controls the movement of the camera within the scene. */ public class CameraController { private final Camera camera; - private final float height = 25; // Höhe der Kamera über dem Spielfeld // Aktueller Winkel in der Kreisbewegung + private final float height = 25; // Height of the camera above the game board /** - * Konstruktor für den CameraController. + * Constructor for the CameraController. * - * @param camera Die Kamera, die gesteuert werden soll - * @param center Der Mittelpunkt der Kreisbewegung (Fokuspunkt) - * @param radius Der Radius der Kreisbewegung - * @param height Die Höhe der Kamera über dem Fokuspunkt - * @param speed Die Geschwindigkeit der Kamerabewegung + * @param camera The camera to be controlled */ public CameraController(Camera camera) { this.camera = camera; @@ -26,27 +22,45 @@ public class CameraController { } /** - * Aktualisiert die Kameraposition und -ausrichtung. + * Updates the camera's position and orientation. * - * @param tpf Zeit pro Frame + * @param tpf Time per frame */ public void update(float tpf) { camera.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); } + /** + * Sets the camera's position based on the field ID. + * + * @param fieldID The ID of the field to which the camera should move + */ public void setPosition(int fieldID) { camera.setLocation(fieldIdToVector(fieldID)); } + /** + * Sets the camera's position using specific coordinates. + * + * @param x The X-coordinate of the new camera position + * @param y The Y-coordinate of the new camera position + */ public void setPosition(float x, float y) { - camera.setLocation(new Vector3f(x,height,y)); + camera.setLocation(new Vector3f(x, height, y)); } + /** + * Maps a field ID to its corresponding position in the game world. + * + * @param fieldID The ID of the field + * @return The position of the field as a {@link Vector3f} + * @throws IllegalArgumentException If the field ID is invalid + */ private Vector3f fieldIdToVector(int fieldID) { - if (fieldID <= 10) return new Vector3f(30,height,0); + if (fieldID <= 10) return new Vector3f(30, height, 0); if (fieldID <= 20) return new Vector3f(0, height, 30); if (fieldID <= 30) return new Vector3f(-30, height, 0); if (fieldID <= 40) return new Vector3f(0, height, -30); else throw new IllegalArgumentException(); } -} +} \ No newline at end of file