A little code refactor

+ new bullet texture added
This commit is contained in:
2024-11-16 16:01:01 +01:00
parent a190e81ba2
commit fcabc0534a
6 changed files with 19 additions and 24 deletions
+8 -8
View File
@@ -20,13 +20,12 @@ public:
Position getPosition();
void move(float deltaX, float deltaY);
void moveLeft();
void moveRight();
void shoot();
virtual void move(float deltaX, float deltaY) = 0;
virtual void moveLeft() = 0;
virtual void moveRight() = 0;
virtual void moveUp() = 0;
virtual void moveDown() = 0;
virtual void shoot() = 0;
std::vector<Bullet>& getBullets();
@@ -39,7 +38,8 @@ public:
protected:
sf::Sprite actorSprite;
sf::Texture actorTexture;
sf::Texture bulletTexture;
sf::Texture bulletTextureLeft;
sf::Texture bulletTextureRight;
Position position;
unsigned int hp;
unsigned int damage;
+6 -6
View File
@@ -7,13 +7,13 @@
class Player : public Actor {
public:
Player(int x, int y, std::string path);
void shoot();
void shoot() override;
void setFirerate(unsigned int firerate);
void move(float deltaX, float deltaY);
void moveLeft();
void moveRight();
void moveUp();
void moveDown();
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
private:
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
};