3 Commits

Author SHA1 Message Date
bafab8d75a counter fixed at 200 2025-01-16 21:31:34 +01:00
92d5f66a91 ultimate implemented 2025-01-16 21:27:14 +01:00
622e814d1c WIP - ultimate 2025-01-16 20:16:08 +01:00
9 changed files with 76 additions and 15 deletions

View File

@@ -50,6 +50,8 @@ public:
void check_Meteor_collisions();
void check_Debuff_collisions();
void handleUltimate();
void spawn_player();
void spawn_enemy();
void spawn_advanced_enemy();
@@ -64,7 +66,9 @@ public:
static ships selectedShip;
static unsigned int score;
static unsigned int ultimateCounter;
sf::Font font;
private:
Background background;
AudioManager audioManager;
@@ -84,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;
@@ -132,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;

View File

@@ -22,6 +22,7 @@ public:
void shoot() override;
void alternate_shoot();
void ultimate_shoot();
void setFirerate(unsigned int firerate);
void move(float deltaX, float deltaY) override;
void moveLeft() override;
@@ -30,13 +31,17 @@ public:
void moveDown() override;
void takeDamage();
void setTripleShot(bool toogle);
void setBulletSpeed(float speed);
void setBulletSpeed(float speed);
bool getUltimateStatus();
void update();
std::vector<Rocket>& getRockets();
void loadTexture();
void setUltimateStatus(bool status);
private:
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
std::vector<Rocket> rockets;
@@ -48,6 +53,7 @@ private:
float bulletSpeed = 10.0f; // prędkość pocisku
bool isImmortal = false; // flaga na immortal
bool tripleShot = false; // flaga na potrójny strzał
bool ultimateShootActive = false;
};

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,6 +2,7 @@
#include <iostream>
#include "../headers/Plansza.h"
#include "../headers/RandomNumberGenerator.h"
#include <SFML/Graphics.hpp>
Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::RenderWindow *mainWindow, ships selectedShip)
: background("../assets/img/background/background.png", 2.0f) {
@@ -105,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();
@@ -122,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) {
@@ -206,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;
@@ -1019,6 +1022,10 @@ std::vector<Meteor> &Plansza::getMeteors() {
void Plansza::update_score() {
if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
score++;
ultimateCounter++;
if (ultimateCounter >= 200) {
ultimateCounter = 200;
}
scoreClock.restart();
}
@@ -1098,4 +1105,31 @@ void Plansza::check_Meteor_collisions() {
}
ships Plansza::selectedShip = none;
unsigned int Plansza::score = 0;
unsigned int Plansza::score = 0;
unsigned int Plansza::ultimateCounter = 0;
void Plansza::handleUltimate() {
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<int>(255 * (1 - elapsedTime));
ultimateShape.setFillColor(sf::Color(255, 255, 255, alpha));
meteors.clear();
debuffs.clear();
enemies.clear();
AEnemies.clear();
BEnemies.clear();
KEnemies.clear();
WEnemies.clear();
window->draw(ultimateShape);
} else {
ship->setUltimateStatus(false);
}
}
}

View File

@@ -58,6 +58,10 @@ void Player::alternate_shoot() {
}
}
void Player::ultimate_shoot() {
ultimateShootActive = true;
}
void Player::update() {
// Wyłącz nieśmiertelność po określonym czasie
if (isImmortal && immortalityClock.getElapsedTime().asSeconds() >= immortalityDuration) {
@@ -129,3 +133,11 @@ void Player::setBulletSpeed(float speed) {
Player* Player::player_ = nullptr;
bool Player::getUltimateStatus() {
return ultimateShootActive;
}
void Player::setUltimateStatus(bool status) {
ultimateShootActive = status;
}

View File

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