40 lines
1.3 KiB
C++
40 lines
1.3 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 {
|
|
public:
|
|
Player(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture, const sf::Texture& rocketTexture);
|
|
void setTextures(const sf::Texture& shipTexture, const sf::Texture& bulletTexture, const sf::Texture& rocketTexture);
|
|
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();
|
|
std::vector<Rocket>& getRockets();
|
|
private:
|
|
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
|
|
std::vector<Rocket> rockets;
|
|
sf::Texture rocketTexture;
|
|
int health = 3; // Liczba punktów życia gracza
|
|
sf::Texture bulletTexture;
|
|
bool isImmortal = false; // flaga na immortal
|
|
sf::Clock immortalityClock; // Zegar kontrolujący czas nieśmiertelności
|
|
float immortalityDuration = 1.5f; // Czas trwania nieśmiertelności w sec
|
|
};
|
|
|
|
|
|
#endif //LOTOSTATEK_PLAYER_H
|