Strzela z kolizja
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user