ultimate implemented

This commit is contained in:
2025-01-16 21:27:14 +01:00
parent 622e814d1c
commit 92d5f66a91
7 changed files with 40 additions and 29 deletions

View File

@@ -66,7 +66,9 @@ public:
static ships selectedShip; static ships selectedShip;
static unsigned int score; static unsigned int score;
static unsigned int ultimateCounter;
sf::Font font; sf::Font font;
private: private:
Background background; Background background;
AudioManager audioManager; AudioManager audioManager;
@@ -86,7 +88,7 @@ private:
sf::Clock heartSpawnClock; sf::Clock heartSpawnClock;
sf::Clock powerUpSpawnClock; sf::Clock powerUpSpawnClock;
sf::Clock debuffSpawnClock; sf::Clock debuffSpawnClock;
// sf::Clock spawnClock; sf::Clock ultimateClock;
sf::Clock scoreClock; sf::Clock scoreClock;
sf::Clock shooterSpawnClock; sf::Clock shooterSpawnClock;
sf::Clock enemySpawnClock; sf::Clock enemySpawnClock;
@@ -134,7 +136,7 @@ private:
// Zmienne prymitywne // Zmienne prymitywne
Boss* boss = nullptr; // Wskaźnik na bossa Boss* boss = nullptr; // Wskaźnik na bossa
sf::Clock bossSpawnClock; // Zegar do spawnowania 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 bossSpawned = false; // Flaga informująca, czy boss został już zespawnowany
bool gameOver = false; bool gameOver = false;

View File

@@ -86,5 +86,6 @@ void AdvancedEnemy::takeDamage() {
if (--hp <= 0) { if (--hp <= 0) {
alive = false; alive = false;
Plansza::score += 10; Plansza::score += 10;
Plansza::ultimateCounter += 10;
} }
} }

View File

@@ -122,5 +122,6 @@ void Bomber::takeDamage() {
if (--hp <= 0) { if (--hp <= 0) {
alive = false; alive = false;
Plansza::score += 15; Plansza::score += 15;
Plansza::ultimateCounter += 15;
} }
} }

View File

@@ -76,5 +76,6 @@ void Enemy::takeDamage() {
if (--hp <= 0) { if (--hp <= 0) {
alive = false; alive = false;
Plansza::score += 5; Plansza::score += 5;
Plansza::ultimateCounter += 5;
} }
} }

View File

@@ -131,5 +131,6 @@ void Kamikadze::takeDamage() {
if (--hp <= 0) { if (--hp <= 0) {
alive = false; alive = false;
Plansza::score += 20; Plansza::score += 20;
Plansza::ultimateCounter += 20;
} }
} }

View File

@@ -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 // TODO: Przenieść obiekt dźwięku wewnątrz klasy Bullet
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
ship->shoot(); ship->shoot();
@@ -123,17 +128,12 @@ void Plansza::update() {
spawn_hearts(); spawn_hearts();
spawn_power_up(); spawn_power_up();
spawn_debuff(); spawn_debuff();
// spawn_enemy(); spawn_enemy();
// spawn_advanced_enemy(); spawn_advanced_enemy();
// spawn_wiazkowiec(); spawn_wiazkowiec();
// spawn_bomber(); spawn_bomber();
// spawn_kamikadze(); spawn_kamikadze();
spawn_boss(); // spawn_boss();
// spawn_enemy();
// spawn_advanced_enemy();
// spawn_wiazkowiec();
// spawn_bomber();
// spawn_kamikadze();
// utrzymanie meteorów i pocisków w ruchu // utrzymanie meteorów i pocisków w ruchu
for (auto &meteor: meteors) { for (auto &meteor: meteors) {
@@ -207,6 +207,8 @@ void Plansza::update() {
ship->setBulletSpeed(10.0f); ship->setBulletSpeed(10.0f);
} }
handleUltimate();
if (gameOver) { if (gameOver) {
sf::RenderWindow errorWindow(sf::VideoMode(350, 200), "The end"); sf::RenderWindow errorWindow(sf::VideoMode(350, 200), "The end");
sf::Font font; sf::Font font;
@@ -1020,6 +1022,7 @@ std::vector<Meteor> &Plansza::getMeteors() {
void Plansza::update_score() { void Plansza::update_score() {
if (scoreClock.getElapsedTime().asMilliseconds() > 500) { if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
score++; score++;
ultimateCounter++;
scoreClock.restart(); scoreClock.restart();
} }
@@ -1100,29 +1103,30 @@ void Plansza::check_Meteor_collisions() {
ships Plansza::selectedShip = none; ships Plansza::selectedShip = none;
unsigned int Plansza::score = 0; unsigned int Plansza::score = 0;
unsigned int Plansza::ultimateCounter = 0;
void Plansza::handleUltimate() { void Plansza::handleUltimate() {
sf::Clock ultimateClock; if (ship->getUltimateStatus() && ultimateCounter >= 200) {
ultimateClock.restart(); float elapsedTime = ultimateClock.getElapsedTime().asSeconds();
if(ship->getUltimateStatus()) { if (ship->getUltimateStatus() && ultimateClock.getElapsedTime().asSeconds() >= 1) {
sf::RectangleShape ultimateShape(sf::Vector2f(600,800)); ultimateCounter = 0;
ultimateShape.setFillColor(sf::Color(255,255,255)); }
if (elapsedTime < 1) {
sf::RectangleShape ultimateShape(sf::Vector2f(600, 800));
int alpha = static_cast<int>(255 * (1 - elapsedTime));
ultimateShape.setFillColor(sf::Color(255, 255, 255, alpha));
meteors.clear(); meteors.clear();
// hearts.clear(); debuffs.clear();
// powerUps.clear(); enemies.clear();
debuffs.clear(); AEnemies.clear();
enemies.clear(); BEnemies.clear();
AEnemies.clear(); KEnemies.clear();
BEnemies.clear(); WEnemies.clear();
KEnemies.clear();
WEnemies.clear();
if(ultimateClock.getElapsedTime().asSeconds() < 1) {
window->draw(ultimateShape); window->draw(ultimateShape);
} else { } else {
ship->setUltimateStatus(false); ship->setUltimateStatus(false);
} }
} }
} }

View File

@@ -200,6 +200,7 @@ void Wiazkowiec::takeDamage() {
if (--hp <= 0) { if (--hp <= 0) {
alive = false; alive = false;
Plansza::score += 10; Plansza::score += 10;
Plansza::ultimateCounter += 10;
} }
} }