public class Camera extends java.lang.Object implements ICamera
Modifier and Type | Field and Description |
---|---|
protected java.awt.geom.Point2D |
focus
Provides the center location for the viewport.
|
Constructor and Description |
---|
Camera()
Instantiates a new camera.
|
Modifier and Type | Method and Description |
---|---|
protected java.awt.geom.Point2D |
clampToMap(java.awt.geom.Point2D focus) |
java.awt.geom.Point2D |
getFocus()
Gets the map location that is focused by this camera.
|
java.awt.geom.Point2D |
getMapLocation(java.awt.geom.Point2D viewPortLocation)
Gets the map location.
|
double |
getPixelOffsetX()
Gets the pixel offset x.
|
double |
getPixelOffsetY()
Gets the pixel offset y.
|
float |
getRenderScale() |
java.awt.geom.Rectangle2D |
getViewport()
Gets the camera region.
|
java.awt.geom.Point2D |
getViewportDimensionCenter(IEntity entity) |
java.awt.geom.Point2D |
getViewportLocation(double x,
double y)
Gets the render location.
|
java.awt.geom.Point2D |
getViewportLocation(IEntity entity)
This method calculates to location for the specified entity in relation to
the focus map location of the camera.
|
java.awt.geom.Point2D |
getViewportLocation(java.awt.geom.Point2D mapLocation)
This method calculates to location for the specified point in relation to
the focus map location of the camera.
|
float |
getZoom() |
boolean |
isClampToMap() |
void |
onFocusChanged(java.util.function.Consumer<java.awt.geom.Point2D> focusCons) |
void |
onZoomChanged(java.util.function.DoubleConsumer zoomCons) |
void |
pan(double x,
double y,
int duration)
Pans the camera over the specified duration (in frames) to the target
location, after accounting for modifications such as clamping to the
map.
|
void |
pan(java.awt.geom.Point2D focus,
int duration)
Pans the camera over the specified duration (in frames) to the target
location, after accounting for modifications such as clamping to the
map.
|
void |
setClampToMap(boolean clampToMap) |
void |
setFocus(double x,
double y) |
void |
setFocus(java.awt.geom.Point2D focus) |
void |
setZoom(float targetZoom,
int delay) |
void |
shake(double intensity,
int delay,
int shakeDuration) |
void |
update()
This method is called by the game loop on all objects that need to update
their attributes.
|
void |
updateFocus() |
protected java.awt.geom.Point2D focus
public java.awt.geom.Point2D getFocus()
ICamera
public java.awt.geom.Point2D getMapLocation(java.awt.geom.Point2D viewPortLocation)
ICamera
getMapLocation
in interface ICamera
viewPortLocation
- the pointpublic double getPixelOffsetX()
ICamera
getPixelOffsetX
in interface ICamera
public double getPixelOffsetY()
ICamera
getPixelOffsetY
in interface ICamera
public java.awt.geom.Rectangle2D getViewport()
ICamera
getViewport
in interface ICamera
public java.awt.geom.Point2D getViewportDimensionCenter(IEntity entity)
getViewportDimensionCenter
in interface ICamera
public java.awt.geom.Point2D getViewportLocation(double x, double y)
ICamera
getViewportLocation
in interface ICamera
x
- the xy
- the ypublic java.awt.geom.Point2D getViewportLocation(IEntity entity)
ICamera
getViewportLocation
in interface ICamera
entity
- the entitypublic java.awt.geom.Point2D getViewportLocation(java.awt.geom.Point2D mapLocation)
ICamera
getViewportLocation
in interface ICamera
mapLocation
- the pointpublic float getRenderScale()
getRenderScale
in interface ICamera
public void onZoomChanged(java.util.function.DoubleConsumer zoomCons)
onZoomChanged
in interface ICamera
public void onFocusChanged(java.util.function.Consumer<java.awt.geom.Point2D> focusCons)
onFocusChanged
in interface ICamera
public void setFocus(java.awt.geom.Point2D focus)
public void shake(double intensity, int delay, int shakeDuration)
public void update()
IUpdateable
update
in interface IUpdateable
public void updateFocus()
updateFocus
in interface ICamera
public boolean isClampToMap()
isClampToMap
in interface ICamera
public void setClampToMap(boolean clampToMap)
setClampToMap
in interface ICamera
protected java.awt.geom.Point2D clampToMap(java.awt.geom.Point2D focus)
public void pan(java.awt.geom.Point2D focus, int duration)
ICamera
public void pan(double x, double y, int duration)
ICamera