better cursor
This commit is contained in:
@@ -66,6 +66,48 @@ void PlayerCursor::goToPosition(const sf::Vector2u& newPosition) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlayerCursor::addPosition(unsigned int x, unsigned int y) {
|
||||||
|
if (y >= this->rows.size()) return false;
|
||||||
|
if (x > this->rows.at(y)) return false;
|
||||||
|
|
||||||
|
this->rows.at(y)++;
|
||||||
|
if (x <= this->position.x) {
|
||||||
|
this->position.x++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerCursor::removePosition(unsigned int x, unsigned int y) {
|
||||||
|
if (y >= this->rows.size()) return false;
|
||||||
|
if (x >= this->rows.at(y)) return false;
|
||||||
|
|
||||||
|
this->rows.at(y)--;
|
||||||
|
if (x < this->position.x) {
|
||||||
|
this->position.x--;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerCursor::addRow(unsigned int position, unsigned int width) {
|
||||||
|
if (position > this->rows.size()) return false;
|
||||||
|
|
||||||
|
this->rows.insert(this->rows.begin() + position, width);
|
||||||
|
if (position <= this->position.y) {
|
||||||
|
this->position.y++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerCursor::removeRow(unsigned int position) {
|
||||||
|
if (position >= this->rows.size()) return false;
|
||||||
|
|
||||||
|
this->rows.erase(this->rows.begin() + position);
|
||||||
|
if (position < this->position.y) {
|
||||||
|
this->position.y--;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const sf::Vector2u& PlayerCursor::getPosition() const {
|
const sf::Vector2u& PlayerCursor::getPosition() const {
|
||||||
return this->position;
|
return this->position;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ class PlayerCursor {
|
|||||||
|
|
||||||
void goToPosition(const sf::Vector2u& newPosition);
|
void goToPosition(const sf::Vector2u& newPosition);
|
||||||
|
|
||||||
|
bool addPosition(unsigned int x, unsigned int y);
|
||||||
|
|
||||||
|
bool removePosition(unsigned int x, unsigned int y);
|
||||||
|
|
||||||
|
bool addRow(unsigned int position, unsigned int width);
|
||||||
|
|
||||||
|
bool removeRow(unsigned int position);
|
||||||
|
|
||||||
const sf::Vector2u& getPosition() const;
|
const sf::Vector2u& getPosition() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user