From 3d83a3a767f4b46b90b71cb1922acf4f6edebab6 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Sun, 5 Jan 2025 18:35:39 +0100 Subject: [PATCH] powerup init commit --- CMakeLists.txt | 2 ++ headers/PowerUp.h | 9 +++++++++ sources/Plansza.cpp | 38 ++++++++++++++++++-------------------- sources/PowerUp.cpp | 1 + 4 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 headers/PowerUp.h create mode 100644 sources/PowerUp.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a5a910f..67e2d81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,8 @@ add_executable(LotoStatek main.cpp sources/Beam.cpp headers/Heart.hpp sources/Heart.cpp + headers/PowerUp.h + sources/PowerUp.cpp ) if(WIN32) diff --git a/headers/PowerUp.h b/headers/PowerUp.h new file mode 100644 index 0000000..fcf53dd --- /dev/null +++ b/headers/PowerUp.h @@ -0,0 +1,9 @@ +#ifndef POWERUP_H +#define POWERUP_H +#include "ObjectItem.hpp" + +class PowerUp : ObjectItem { + +}; + +#endif //POWERUP_H diff --git a/sources/Plansza.cpp b/sources/Plansza.cpp index 0e9c294..2e423c5 100644 --- a/sources/Plansza.cpp +++ b/sources/Plansza.cpp @@ -111,13 +111,13 @@ void Plansza::update() { ship->update(); // migotanie statku update_score(); // naliczanie punktów // Sprawnowanie wszystkich rodzajów wrogów - // spawn_meteor(); - // spawn_hearts(); - // spawn_enemy(); - // spawn_advanced_enemy(); + spawn_meteor(); + spawn_hearts(); + spawn_enemy(); + spawn_advanced_enemy(); spawn_wiazkowiec(); - // spawn_bomber(); - // spawn_kamikadze(); + spawn_bomber(); + spawn_kamikadze(); // utrzymanie meteorów i pocisków w ruchu for (auto &meteor: meteors) { @@ -697,7 +697,6 @@ void Plansza::update() { } // Meteor-related niżej - void Plansza::update_meteors() { // usuwanie meteorów, które wyleciały poza ekran for (auto &meteor: meteors) { @@ -721,14 +720,23 @@ void Plansza::spawn_meteor() { } void Plansza::spawn_hearts() { - if (heartSpawnClock.getElapsedTime().asSeconds() > rand() % 26 + 5) { // randomowy spawn meteorytów od 5 do 30 sekundy - if (hearts.size() < 5) { // jeśli jest mniej niż 5 meteorów na planszy + if (heartSpawnClock.getElapsedTime().asSeconds() > rand() % 26 + 5) { // randomowy spawn serduszek od 5 do 30 sekundy + if (hearts.size() < 5) { // jeśli jest mniej niż 5 serduszek na planszy hearts.emplace_back(RandomNumberGenerator::getRandomNumber(50, 499), -100, heartTexture); } heartSpawnClock.restart(); } } +void Plansza::update_hearts() { + // usuwanie serduszek, które wyleciały poza ekran + for (auto& heart : hearts) { + if(heart.getStatus()) { + hearts.erase(hearts.begin()); + } + } +} + void Plansza::spawn_player() { ship = Player::getInstance(static_cast(window->getSize().x) / 2, static_cast(window->getSize().y) - 100, this->playerTexture); ship->loadTexture(); @@ -776,7 +784,7 @@ void Plansza::spawn_kamikadze() { } void Plansza::spawn_wiazkowiec() { - if (WiazkowiecSpawnClock.getElapsedTime().asSeconds() >= 5) { // Spawn co 10 sekund + if (WiazkowiecSpawnClock.getElapsedTime().asSeconds() >= 50) { // Spawn co 10 sekund if (WEnemies.size() < 1) { int spawnX = RandomNumberGenerator::getRandomNumber(50, size.width - 50); Wiazkowiec wiazkowiec(spawnX, -50, WiazkowiecTexture, window); @@ -788,16 +796,6 @@ void Plansza::spawn_wiazkowiec() { } } - -void Plansza::update_hearts() { - // usuwanie serduszek, które wyleciały poza ekran - for (auto& heart : hearts) { - if(heart.getStatus()) { - hearts.erase(hearts.begin()); - } - } -} - Size Plansza::getSize() { return size; } diff --git a/sources/PowerUp.cpp b/sources/PowerUp.cpp new file mode 100644 index 0000000..85f39fa --- /dev/null +++ b/sources/PowerUp.cpp @@ -0,0 +1 @@ +#include "../headers/PowerUp.h" \ No newline at end of file