5 przeciwnikow, jakos to dziala

This commit is contained in:
2024-12-11 23:47:20 +01:00
parent 1c0e5d0293
commit 38fd71b8e6
8 changed files with 158 additions and 42 deletions

View File

@@ -34,17 +34,40 @@ 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";
void Player::update() {
// Wyłącz nieśmiertelność po określonym czasie
if (isImmortal && immortalityClock.getElapsedTime().asSeconds() >= immortalityDuration) {
isImmortal = false;
std::cout << "Immortality ended.\n";
}
// Efekt migania podczas nieśmiertelności
if (isImmortal) {
if (static_cast<int>(immortalityClock.getElapsedTime().asMilliseconds() / 200) % 2 == 0) {
actorSprite.setColor(sf::Color(255, 255, 255, 128)); // Półprzezroczysty
} else {
actorSprite.setColor(sf::Color(255, 255, 255, 255)); // Normalny
}
} else {
actorSprite.setColor(sf::Color(255, 255, 255, 255)); // Normalny
}
}
void Player::takeDamage() {
if (!isImmortal) {
if (health > 0) {
health--;
std::cout << "Player hit! Remaining health: " << health << "\n";
isImmortal = true; // Aktywuj chwilową nieśmiertelność
immortalityClock.restart();
if (health <= 0) {
std::cout << "Player has been destroyed!\n";
std::cout << "You lost the game!\n";
}
}
}
}