public class Coordinate extends AbstractPosition
SQRT12, SQRT2
Constructor and Description |
---|
Coordinate(Coordinate coord)
Creates a new coordinate from an existing coordinate
|
Coordinate(int x,
int y,
float height,
boolean relative)
Creates a coordiante.
|
Coordinate(int x,
int y,
int z,
boolean relative)
Creates a coordiante refering to a position on the map.
|
Modifier and Type | Method and Description |
---|---|
Coordinate |
addVector(float[] vector)
Add a vector to the coordinates.
|
Coordinate |
addVector(float x,
float y,
float z)
Add a vector to the coordinates.
|
Coordinate |
addVector(com.badlogic.gdx.math.Vector3 vector) |
Coordinate |
clampToMap()
Clamps x and y coordiantes if outside of map.
|
Coordinate |
clampToMapIncludingZ() |
Coordinate |
cpy() |
int[] |
getAbs() |
int |
getAbsX()
Absolute coordinates are independent of the currently loaded chunks.
|
int |
getAbsY()
Absolute coordinates are independent of the currently loaded chunks.
|
Block |
getBlock() |
Block |
getBlockClamp() |
Block |
getBlockSafe()
Checks of coordinates are valid before fetching the Block.
|
int[] |
getCellOffset() |
Coordinate |
getCoord()
If needed calculates it.
|
int |
getDepth()
Returns the depth of the object.
|
static int |
getNeighbourSide(float x,
float y)
Returns the field-id where the coordiantes are inside in relation to the current field.
|
Point |
getPoint()
If needed calculates it.
|
int |
getProjectedPosX()
Calculate projected position.
|
int |
getProjectedPosY()
Calculate projected position.
|
int[] |
getRel() |
int |
getRelX()
Gets the X coordinate relative to the map.
|
int |
getRelY()
Gets the Y coordinate relative to the map.
|
protected int |
getX() |
protected int |
getY() |
int |
getZClamp()
Checks if the calculated value is inside the map dimensions and if not clamps it to the map dimensions.
|
boolean |
hasOffset()
Has the object an offset (pos vector)?
|
boolean |
hidingPastBlock()
The block hides the past block when it has sides and is not transparent (like normal block)
|
Coordinate |
neighbourSidetoCoords(int neighbourSide)
Get the neighbour coordinates of the neighbour of the coords you give.
7 \ 0 / 1
------- 6 | 8 | 2 ------- 5 / 4 \ 3 |
boolean |
onLoadedMap()
Checks if the coordiantes are accessable with the currently loaded Chunks.
|
void |
setBlock(Block block)
Set a block in the map where the coordinate is pointing to.
|
void |
setCellOffsetZ(int height)
Set the vertical offset in the cell, where the coordiante is pointing at.
|
void |
setRelX(int x)
Set the coordiantes X component.
|
void |
setRelY(int y)
Set the coordiantes Y component.
|
void |
setZ(int z)
Set the coordinates Z component.
|
getHeight, getReferenceX, getReferenceY, getZ, setHeight
public Coordinate(int x, int y, int z, boolean relative)
x
- The x value as coordinate.y
- The y value as coordinate.z
- The z value as coordinate.relative
- True when the coordiantes are relative to the currently loaded map. False when they are absolute.public Coordinate(int x, int y, float height, boolean relative)
x
- The x value as coordinate.y
- The y value as coordinate.height
- The z value as height.relative
- True when the coordiantes are relative to the currently loaded map. False when they are absolute.public Coordinate(Coordinate coord)
coord
- the Coordinate you want to copypublic int getRelX()
public int getRelY()
public int getAbsX()
public int getAbsY()
public int getZClamp()
AbstractPosition.getZ()
public int[] getRel()
public int[] getAbs()
public int[] getCellOffset()
public void setRelX(int x)
x
- public void setRelY(int y)
y
- public void setZ(int z)
z
- public void setCellOffsetZ(int height)
height
- public void setBlock(Block block)
block
- the block you want to set.public Coordinate addVector(float[] vector)
addVector
in class AbstractPosition
vector
- public Coordinate addVector(com.badlogic.gdx.math.Vector3 vector)
addVector
in class AbstractPosition
vector
- public Coordinate addVector(float x, float y, float z)
addVector
in class AbstractPosition
x
- y
- z
- public Block getBlock()
getBlock
in class AbstractPosition
AbstractPosition.getBlockSafe()
public Block getBlockSafe()
getBlockSafe
in class AbstractPosition
AbstractPosition.getBlock()
public Block getBlockClamp()
public boolean hasOffset()
public boolean hidingPastBlock()
public Coordinate cpy()
cpy
in class AbstractPosition
public boolean onLoadedMap()
onLoadedMap
in class AbstractPosition
public static int getNeighbourSide(float x, float y)
neighbourSidetoCoords(int)
with the parameter found by this function.
The numbering of the sides:x
- game-space-coordinates, value in pixelsy
- game-space-coordinates, value in pixelsneighbourSidetoCoords(int)
public Coordinate neighbourSidetoCoords(int neighbourSide)
neighbourSide
- the side number of the given coordinatesprotected int getX()
protected int getY()
public Point getPoint()
AbstractPosition
getPoint
in class AbstractPosition
public Coordinate getCoord()
AbstractPosition
getCoord
in class AbstractPosition
public int getProjectedPosX()
AbstractPosition
getProjectedPosX
in class AbstractPosition
public int getProjectedPosY()
AbstractPosition
getProjectedPosY
in class AbstractPosition
public int getDepth()
AbstractPosition
getDepth
in class AbstractPosition
public Coordinate clampToMap()
public Coordinate clampToMapIncludingZ()