Strzela z kolizja

This commit is contained in:
2024-12-09 23:09:44 +01:00
parent 13066709a7
commit a81cf284d0
8 changed files with 91 additions and 51 deletions

View File

@@ -1,4 +1,10 @@
#include "../headers/Player.h"
#include <iostream>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>
#include "../headers/Bullet.h"
Player::Player(int x, int y, std::string path) : Actor(x, y, path) {
@@ -22,6 +28,24 @@ void Player::alternate_shoot() {
}
}
void Player::takeDamage() {
if (health > 0) {
health--;
std::cout << "Player hit! Remaining health: " << health << "\n";
if (health <= 0) {
std::cout << "Player has been destroyed!\n";
std::cout << "You lost the game!\n";
}
}
}
bool Player::isAlive() const {
return health > 0;
}
void Player::setFirerate(unsigned int firerate) {
this->firerate = firerate;
}