mirror of
https://github.com/Motschen/Adventura.git
synced 2025-12-17 04:05:10 +01:00
docs: more comments
This commit is contained in:
39
blockPos.hpp
39
blockPos.hpp
@@ -3,28 +3,67 @@ class BlockPos {
|
||||
int x;
|
||||
int y;
|
||||
public:
|
||||
/**
|
||||
* Define an in-world position.
|
||||
*
|
||||
* @param x The x-coordinate of the BlockPos.
|
||||
* @param y The y-coordinate of the BlockPos.
|
||||
*/
|
||||
BlockPos(int x, int y) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The x-coordinate of the BlockPos.
|
||||
*/
|
||||
int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The y-coordinate of the BlockPos.
|
||||
*/
|
||||
int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The x-coordinate of the BlockPos as an unsigned integer.
|
||||
* @pre x >= 0
|
||||
*/
|
||||
unsigned int getUnsignedX() {
|
||||
return static_cast<unsigned int>(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The y-coordinate of the BlockPos as an unsigned integer.
|
||||
* @pre y >= 0
|
||||
*/
|
||||
unsigned int getUnsignedY() {
|
||||
return static_cast<unsigned int>(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the BlockPos is negative, false otherwise.
|
||||
*
|
||||
* A BlockPos is considered negative if either the x-coordinate or the y-coordinate is negative.
|
||||
*/
|
||||
bool isNegative() {
|
||||
return x < 0 || y < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given coordinates to the BlockPos.
|
||||
*
|
||||
* @param x The x-coordinate to add.
|
||||
* @param y The y-coordinate to add.
|
||||
* @return The BlockPos with the given coordinates added.
|
||||
*/
|
||||
BlockPos add(int x, int y) {
|
||||
return BlockPos(this->x + x, this->y + y);
|
||||
}
|
||||
|
||||
BlockPos operator+(BlockPos offset) {
|
||||
return BlockPos(this->getX() + offset.getX(), this->getY() + offset.getY());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user