diff --git a/headers/Plansza.h b/headers/Plansza.h index b03f223..ea9271e 100644 --- a/headers/Plansza.h +++ b/headers/Plansza.h @@ -66,7 +66,9 @@ public: static ships selectedShip; static unsigned int score; + static unsigned int ultimateCounter; sf::Font font; + private: Background background; AudioManager audioManager; @@ -86,7 +88,7 @@ private: sf::Clock heartSpawnClock; sf::Clock powerUpSpawnClock; sf::Clock debuffSpawnClock; - // sf::Clock spawnClock; + sf::Clock ultimateClock; sf::Clock scoreClock; sf::Clock shooterSpawnClock; sf::Clock enemySpawnClock; @@ -134,7 +136,7 @@ private: // Zmienne prymitywne Boss* boss = nullptr; // Wskaźnik na bossa sf::Clock bossSpawnClock; // Zegar do spawnowania bossa - unsigned int nextBossScoreThreshold = 1; // Próg punktowy dla spawnu bossa + unsigned int nextBossScoreThreshold = 1000; // Próg punktowy dla spawnu bossa bool bossSpawned = false; // Flaga informująca, czy boss został już zespawnowany bool gameOver = false; diff --git a/sources/AdvancedEnemy.cpp b/sources/AdvancedEnemy.cpp index 746189a..635dd1a 100644 --- a/sources/AdvancedEnemy.cpp +++ b/sources/AdvancedEnemy.cpp @@ -86,5 +86,6 @@ void AdvancedEnemy::takeDamage() { if (--hp <= 0) { alive = false; Plansza::score += 10; + Plansza::ultimateCounter += 10; } } \ No newline at end of file diff --git a/sources/Bomber.cpp b/sources/Bomber.cpp index d56bd99..2f7e55d 100644 --- a/sources/Bomber.cpp +++ b/sources/Bomber.cpp @@ -122,5 +122,6 @@ void Bomber::takeDamage() { if (--hp <= 0) { alive = false; Plansza::score += 15; + Plansza::ultimateCounter += 15; } } \ No newline at end of file diff --git a/sources/Enemy.cpp b/sources/Enemy.cpp index 731281a..9056f2f 100644 --- a/sources/Enemy.cpp +++ b/sources/Enemy.cpp @@ -76,5 +76,6 @@ void Enemy::takeDamage() { if (--hp <= 0) { alive = false; Plansza::score += 5; + Plansza::ultimateCounter += 5; } } diff --git a/sources/Kamikadze.cpp b/sources/Kamikadze.cpp index f2fd0c2..81b8712 100644 --- a/sources/Kamikadze.cpp +++ b/sources/Kamikadze.cpp @@ -131,5 +131,6 @@ void Kamikadze::takeDamage() { if (--hp <= 0) { alive = false; Plansza::score += 20; + Plansza::ultimateCounter += 20; } } \ No newline at end of file diff --git a/sources/Plansza.cpp b/sources/Plansza.cpp index bd2a02f..33c4110 100644 --- a/sources/Plansza.cpp +++ b/sources/Plansza.cpp @@ -106,6 +106,11 @@ void Plansza::update() { } } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && !ship->getUltimateStatus() && ultimateCounter >= 200) { + ultimateClock.restart(); + ship->ultimate_shoot(); + } + // TODO: Przenieść obiekt dźwięku wewnątrz klasy Bullet if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { ship->shoot(); @@ -123,17 +128,12 @@ void Plansza::update() { spawn_hearts(); spawn_power_up(); spawn_debuff(); - // spawn_enemy(); - // spawn_advanced_enemy(); - // spawn_wiazkowiec(); - // spawn_bomber(); - // spawn_kamikadze(); - spawn_boss(); - // spawn_enemy(); - // spawn_advanced_enemy(); - // spawn_wiazkowiec(); - // spawn_bomber(); - // spawn_kamikadze(); + spawn_enemy(); + spawn_advanced_enemy(); + spawn_wiazkowiec(); + spawn_bomber(); + spawn_kamikadze(); + // spawn_boss(); // utrzymanie meteorów i pocisków w ruchu for (auto &meteor: meteors) { @@ -207,6 +207,8 @@ void Plansza::update() { ship->setBulletSpeed(10.0f); } + handleUltimate(); + if (gameOver) { sf::RenderWindow errorWindow(sf::VideoMode(350, 200), "The end"); sf::Font font; @@ -1020,6 +1022,7 @@ std::vector &Plansza::getMeteors() { void Plansza::update_score() { if (scoreClock.getElapsedTime().asMilliseconds() > 500) { score++; + ultimateCounter++; scoreClock.restart(); } @@ -1100,29 +1103,30 @@ void Plansza::check_Meteor_collisions() { ships Plansza::selectedShip = none; unsigned int Plansza::score = 0; +unsigned int Plansza::ultimateCounter = 0; void Plansza::handleUltimate() { - sf::Clock ultimateClock; - ultimateClock.restart(); - if(ship->getUltimateStatus()) { - sf::RectangleShape ultimateShape(sf::Vector2f(600,800)); - ultimateShape.setFillColor(sf::Color(255,255,255)); + if (ship->getUltimateStatus() && ultimateCounter >= 200) { + float elapsedTime = ultimateClock.getElapsedTime().asSeconds(); + if (ship->getUltimateStatus() && ultimateClock.getElapsedTime().asSeconds() >= 1) { + ultimateCounter = 0; + } + if (elapsedTime < 1) { + sf::RectangleShape ultimateShape(sf::Vector2f(600, 800)); + int alpha = static_cast(255 * (1 - elapsedTime)); + ultimateShape.setFillColor(sf::Color(255, 255, 255, alpha)); - meteors.clear(); -// hearts.clear(); -// powerUps.clear(); - debuffs.clear(); - enemies.clear(); - AEnemies.clear(); - BEnemies.clear(); - KEnemies.clear(); - WEnemies.clear(); + meteors.clear(); + debuffs.clear(); + enemies.clear(); + AEnemies.clear(); + BEnemies.clear(); + KEnemies.clear(); + WEnemies.clear(); - if(ultimateClock.getElapsedTime().asSeconds() < 1) { window->draw(ultimateShape); } else { ship->setUltimateStatus(false); } - } } diff --git a/sources/Wiazkowiec.cpp b/sources/Wiazkowiec.cpp index f73de42..878662f 100644 --- a/sources/Wiazkowiec.cpp +++ b/sources/Wiazkowiec.cpp @@ -200,6 +200,7 @@ void Wiazkowiec::takeDamage() { if (--hp <= 0) { alive = false; Plansza::score += 10; + Plansza::ultimateCounter += 10; } }