5 przeciwnikow, jakos to dziala
This commit is contained in:
@@ -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";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user