docs: more comments

This commit is contained in:
Martin Prokoph
2025-02-07 15:54:33 +01:00
parent c813274a6c
commit 813e47a25e
10 changed files with 166 additions and 6 deletions

View File

@@ -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());
}