feat(shield): added shields

This commit is contained in:
2024-01-23 11:40:46 +01:00
parent 15c745d7c0
commit d67394aaec
10 changed files with 127 additions and 10 deletions
+6 -3
View File
@@ -1,14 +1,17 @@
#include "Player.h";
Player::Player(Vector2u screenSize): _screenWidth(screenSize.x) {
_shape = CircleShape(40, 3);
_shape = CircleShape(screenSize.x / 70, 3);
_shape.setFillColor(Color(52, 252, 5));
_shape.setPosition(_screenWidth / 2.f, screenSize.y - _shape.getScale().y - 50);
float shapeHeight = _shape.getRadius() * 1.5;
_shape.setPosition(_screenWidth / 2.f, screenSize.y - shapeHeight);
}
void Player::move(int direction) {
float max = _screenWidth - (_shape.getRadius() * 2);
float result = 5 * direction;
float result = (_screenWidth / 724.0)*direction;
// Prevent leaving the window
if (_shape.getPosition().x + result < 0 || _shape.getPosition().x + result > max) {