feat(player): added movements

This commit is contained in:
2024-01-08 14:13:16 +01:00
parent c7c7c91818
commit 0fed252afd
8 changed files with 113 additions and 4 deletions
+25
View File
@@ -0,0 +1,25 @@
#include "Player.h";
void Player::DrawPlayer() {
PlayerShape.setFillColor(Color(52, 252, 5));
PlayerShape.setPosition(Vector2f(_window.getSize().x / 2 + _x, _window.getSize().y - PlayerShape.getScale().y - 50));
_window.draw(PlayerShape);
}
void Player::Move(int direction) {
int result = _x + _velocity * direction;
int minX = _window.getSize().x / 2 * -1;
int maxX = _window.getSize().x / 2 - ((int)PlayerShape.getRadius() * 2);
if (result < minX) {
result = minX;
}
else if (result > maxX) {
result = maxX;
}
else {
_x = result;
}
}