Statek miga
przy uderzeniu w meteoryt
This commit is contained in:
@@ -7,6 +7,7 @@ Player::Player(int x, int y, std::string path) : Actor(x, y, std::move(path)) {
|
||||
rocketTexture.loadFromFile("../assets/img/rockets/Rocket_111.png");
|
||||
hp = 3;
|
||||
damageDealClock.restart();
|
||||
originalColor = actorSprite.getColor();
|
||||
};
|
||||
|
||||
void Player::shoot() {
|
||||
@@ -25,6 +26,27 @@ void Player::alternate_shoot() {
|
||||
}
|
||||
}
|
||||
|
||||
void Player::onHit() {
|
||||
dealDamage();
|
||||
isBlinking = true;
|
||||
}
|
||||
|
||||
void Player::update() {
|
||||
if (isBlinking) {
|
||||
auto elapsed = damageDealClock.getElapsedTime().asMilliseconds();
|
||||
if (elapsed < 1000) { // miganie przez 1 sekundę
|
||||
if ((elapsed / 100) % 2 == 0) {
|
||||
actorSprite.setColor(sf::Color(255, 255, 255, 128)); // półprzeźroczysty
|
||||
} else {
|
||||
actorSprite.setColor(originalColor); // oryginalny kolor
|
||||
}
|
||||
} else {
|
||||
isBlinking = false;
|
||||
actorSprite.setColor(originalColor); // przywróć oryginalny kolor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::setFirerate(unsigned int firerate) {
|
||||
this->firerate = firerate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user