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
Andrii Solianyk fdf67f4bc2 Merge remote-tracking branch 'origin/serduszka'
# Conflicts:
#	CMakeLists.txt
#	headers/Actor.h
#	headers/Plansza.h
#	headers/Player.h
#	sources/Plansza.cpp
#	sources/Player.cpp
2024-12-13 19:48:39 +01:00

56 lines
1.6 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();
bool isAlive() const;
void update();
void onHit();
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;
bool isBlinking = false;
sf::Color originalColor;
sf::Clock immortalityClock; // Zegar kontrolujący czas nieśmiertelności
int health = 3; // Liczba punktów życia gracza
float immortalityDuration = 1.5f; // Czas trwania nieśmiertelności w sec
bool isImmortal = false; // flaga na immortal
};
#endif //LOTOSTATEK_PLAYER_H