Class Camera

java.lang.Object
org.collebol.client.gui.graphics.Camera

public class Camera extends Object
The Camera class represents a camera in a 2D space. It has a position (Vector2D), zoom level (float), origin-point (Vector2D), rotation ° (float) ambientLight (default light float array) and a boolean if you want to use lighting.

The class provides methods to move the camera by a given delta and to zoom in or out by a given factor. Additionally, it includes getter and setter methods for the position and zoom level.

Usage:

     Camera camera = new Camera(
          new Vector(0, 0),
          3, //zoom = scale
          0, //rotation in °
          engine //EJGEngine instance
     );
 
Since:
1.0-dev
Author:
ColleBol - contact@collebol.org
  • Constructor Details

    • Camera

      public Camera(Vector2D position, float zoom, float rotation, EJGEngine e)
  • Method Details

    • getOrigin

      public Vector2D getOrigin()
      The origin of the Camera represents the reference point from which the camera's position and zoom are calculated.
      Returns:
      origin point as Vector
    • setOrigin

      public void setOrigin(Vector2D origin)
      The origin of the Camera represents the reference point from which the camera's position and zoom are calculated.
      Parameters:
      origin - as vector
    • move

      public void move(Vector2D delta)
      Add a amount to the current camera position
      Parameters:
      delta - amount. X and Y
    • zoom

      public void zoom(float factor)
      Zoom the current canvas.
      Parameters:
      factor - the amount will be added.
    • getPosition

      public Vector2D getPosition()
      Returns:
      current vector position of the camera.
    • setPosition

      public void setPosition(Vector2D position)
      Parameters:
      position - as vector x and y.
    • getZoom

      public float getZoom()
      Returns:
      current zoom factor.
    • setZoom

      public void setZoom(float zoom)
      Parameters:
      zoom - set zoom factor (float).
    • getRotation

      public float getRotation()
    • setRotation

      public void setRotation(float rotation)
    • calculate

      public CameraCalculator calculate()
    • getGameLocation

      public GameLocation getGameLocation()
      This method will convert the position as Vector2D to the GameLocation where the origin point is pointed at.
      Returns:
      GameLocation from vector
    • setGameLocation

      public void setGameLocation(GameLocation location)
      This method will set the GameLocation to a Panel (Vector2D) position where the origin point is pointed at.
      Parameters:
      location - the GameLocation the Camera must go to.
    • getAmbientLight

      public float[] getAmbientLight()
    • setAmbientLight

      public void setAmbientLight(float[] ambientLight)
    • isLighting

      public boolean isLighting()
    • setLighting

      public void setLighting(boolean lighting)