This repository has been archived on 2025-06-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
LotoStatek/headers/Player.h

53 lines
1.5 KiB
C++

#ifndef LOTOSTATEK_PLAYER_H
#define LOTOSTATEK_PLAYER_H
#include <chrono>
#include <SFML/System/Clock.hpp>
#include "Actor.h"
#include "Rocket.h"
class Player : public Actor {
// Zgodnie z refactoring.guru singleton pattern
// https://refactoring.guru/design-patterns/singleton/cpp/example
protected:
Player(int x, int y, const sf::Texture &texture);
static Player* player_;
public:
Player(Player &other) = delete;
void operator=(const Player &) = delete;
static Player* getInstance(int x, int y, const sf::Texture &texture);
// Tu się kończy definicja singletona
void shoot() override;
void alternate_shoot();
void setFirerate(unsigned int firerate);
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void takeDamage();
void setTripleShot(bool toogle);
void update();
std::vector<Rocket>& getRockets();
void loadTexture();
private:
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
std::vector<Rocket> rockets;
sf::Texture rocketTexture;
sf::Texture bulletTexture;
sf::Color originalColor;
sf::Clock immortalityClock; // Zegar kontrolujący czas nieśmiertelności
float immortalityDuration = 1.5f; // Czas trwania nieśmiertelności w sec
bool isImmortal = false; // flaga na immortal
bool tripleShot = false; // flaga na potrójny strzał
};
#endif //LOTOSTATEK_PLAYER_H