ultimate implemented
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -86,5 +86,6 @@ void AdvancedEnemy::takeDamage() {
|
||||
if (--hp <= 0) {
|
||||
alive = false;
|
||||
Plansza::score += 10;
|
||||
Plansza::ultimateCounter += 10;
|
||||
}
|
||||
}
|
||||
@@ -122,5 +122,6 @@ void Bomber::takeDamage() {
|
||||
if (--hp <= 0) {
|
||||
alive = false;
|
||||
Plansza::score += 15;
|
||||
Plansza::ultimateCounter += 15;
|
||||
}
|
||||
}
|
||||
@@ -76,5 +76,6 @@ void Enemy::takeDamage() {
|
||||
if (--hp <= 0) {
|
||||
alive = false;
|
||||
Plansza::score += 5;
|
||||
Plansza::ultimateCounter += 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,5 +131,6 @@ void Kamikadze::takeDamage() {
|
||||
if (--hp <= 0) {
|
||||
alive = false;
|
||||
Plansza::score += 20;
|
||||
Plansza::ultimateCounter += 20;
|
||||
}
|
||||
}
|
||||
@@ -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<Meteor> &Plansza::getMeteors() {
|
||||
void Plansza::update_score() {
|
||||
if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
|
||||
score++;
|
||||
ultimateCounter++;
|
||||
scoreClock.restart();
|
||||
}
|
||||
|
||||
@@ -1100,17 +1103,20 @@ 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()) {
|
||||
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));
|
||||
ultimateShape.setFillColor(sf::Color(255,255,255));
|
||||
int alpha = static_cast<int>(255 * (1 - elapsedTime));
|
||||
ultimateShape.setFillColor(sf::Color(255, 255, 255, alpha));
|
||||
|
||||
meteors.clear();
|
||||
// hearts.clear();
|
||||
// powerUps.clear();
|
||||
debuffs.clear();
|
||||
enemies.clear();
|
||||
AEnemies.clear();
|
||||
@@ -1118,11 +1124,9 @@ void Plansza::handleUltimate() {
|
||||
KEnemies.clear();
|
||||
WEnemies.clear();
|
||||
|
||||
if(ultimateClock.getElapsedTime().asSeconds() < 1) {
|
||||
window->draw(ultimateShape);
|
||||
} else {
|
||||
ship->setUltimateStatus(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,7 @@ void Wiazkowiec::takeDamage() {
|
||||
if (--hp <= 0) {
|
||||
alive = false;
|
||||
Plansza::score += 10;
|
||||
Plansza::ultimateCounter += 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user