From 94eddb457feff1f1e6ef870d1e927822f5cdad10 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Sat, 14 Dec 2024 20:32:08 +0100 Subject: [PATCH] =?UTF-8?q?Implementacja=20naliczania=20punkt=C3=B3w=20za?= =?UTF-8?q?=20zabicie=20wrog=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- headers/Plansza.h | 2 +- sources/AdvancedEnemy.cpp | 2 ++ sources/Bomber.cpp | 2 ++ sources/Enemy.cpp | 2 ++ sources/Kamikadze.cpp | 8 +++++--- sources/Plansza.cpp | 4 +++- sources/Wiazkowiec.cpp | 5 +++-- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/headers/Plansza.h b/headers/Plansza.h index ad77a10..d1698ba 100644 --- a/headers/Plansza.h +++ b/headers/Plansza.h @@ -46,6 +46,7 @@ public: } static ships selectedShip; + static unsigned int score; private: Background background; AudioManager audioManager; @@ -87,7 +88,6 @@ private: std::vector hearts; std::vector heartStats; bool gameOver = false; - unsigned int score = 0; }; #endif //PLANSZA_H diff --git a/sources/AdvancedEnemy.cpp b/sources/AdvancedEnemy.cpp index 44be9ee..516454b 100644 --- a/sources/AdvancedEnemy.cpp +++ b/sources/AdvancedEnemy.cpp @@ -1,5 +1,6 @@ #include "../headers/AdvancedEnemy.h" #include "../headers/Bullet.h" +#include "../headers/Plansza.h" AdvancedEnemy::AdvancedEnemy(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) { actorSprite.setTexture(texture); @@ -85,5 +86,6 @@ bool AdvancedEnemy::isAlive() const { void AdvancedEnemy::takeDamage() { if (--hp <= 0) { alive = false; + Plansza::score += 10; } } \ No newline at end of file diff --git a/sources/Bomber.cpp b/sources/Bomber.cpp index 7a81cd9..9d29b9a 100644 --- a/sources/Bomber.cpp +++ b/sources/Bomber.cpp @@ -1,5 +1,6 @@ #include "../headers/Bomber.h" #include "../headers/Bullet.h" +#include "../headers/Plansza.h" #include Bomber::Bomber(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture) : Actor(x, y, texture) { @@ -121,5 +122,6 @@ bool Bomber::isAlive() const { void Bomber::takeDamage() { if (--hp <= 0) { alive = false; + Plansza::score += 15; } } \ No newline at end of file diff --git a/sources/Enemy.cpp b/sources/Enemy.cpp index 9319e39..484fba0 100644 --- a/sources/Enemy.cpp +++ b/sources/Enemy.cpp @@ -1,5 +1,6 @@ #include "../headers/Enemy.h" #include "../headers/Bullet.h" +#include "../headers/Plansza.h" Enemy::Enemy(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) { actorSprite.setTexture(texture); @@ -75,5 +76,6 @@ bool Enemy::isAlive() const { void Enemy::takeDamage() { if (--hp <= 0) { alive = false; + Plansza::score += 5; } } diff --git a/sources/Kamikadze.cpp b/sources/Kamikadze.cpp index 5067acd..f78833a 100644 --- a/sources/Kamikadze.cpp +++ b/sources/Kamikadze.cpp @@ -1,9 +1,10 @@ -#include "../headers/Kamikadze.h" - #include #include - +#include "../headers/Kamikadze.h" #include "../headers/RandomNumberGenerator.h" +#include "../headers/Plansza.h" + + Kamikadze::Kamikadze(int x, int y, const sf::Texture& texture) : Actor(x, y, texture) { actorSprite.setTexture(texture); @@ -130,5 +131,6 @@ bool Kamikadze::isAlive() const { void Kamikadze::takeDamage() { if (--hp <= 0) { alive = false; + Plansza::score += 20; } } \ No newline at end of file diff --git a/sources/Plansza.cpp b/sources/Plansza.cpp index bbaa34d..8677637 100644 --- a/sources/Plansza.cpp +++ b/sources/Plansza.cpp @@ -455,6 +455,7 @@ void Plansza::update() { wiazkowiec.render(*window); } + // TODO: naprawić to co średnio działa // Usuwanie pocisków, które są poza ekranem srednio to dziala for (auto enemyIt = enemies.begin(); enemyIt != enemies.end();) { for (auto bulletIt = enemyIt->getBullets().begin(); bulletIt != enemyIt->getBullets().end();) { @@ -815,4 +816,5 @@ void Plansza::update_score() { window->draw(text); } -ships Plansza::selectedShip = none; \ No newline at end of file +ships Plansza::selectedShip = none; +unsigned int Plansza::score = 0; \ No newline at end of file diff --git a/sources/Wiazkowiec.cpp b/sources/Wiazkowiec.cpp index c51371b..d97d0c1 100644 --- a/sources/Wiazkowiec.cpp +++ b/sources/Wiazkowiec.cpp @@ -1,9 +1,9 @@ #include "../headers/Wiazkowiec.h" #include - -#include "../headers/Bullet.h" #include +#include "../headers/Plansza.h" + Wiazkowiec::Wiazkowiec(int x, int y, const sf::Texture& texture) : Actor(x, y, texture), beam(0, 0, 50.f, 50.f, sf::Color::Red) { actorSprite.setTexture(texture); @@ -176,6 +176,7 @@ bool Wiazkowiec::isAlive() const { void Wiazkowiec::takeDamage() { if (--hp <= 0) { alive = false; + Plansza::score += 10; } }