From a49a76f8efc6d791049cc9aa0a79aa6d79e2b3ee Mon Sep 17 00:00:00 2001 From: Wojtek Date: Thu, 8 Feb 2024 04:54:48 +0100 Subject: [PATCH] nitroes --- grk/project/src/ex_9_1.hpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/grk/project/src/ex_9_1.hpp b/grk/project/src/ex_9_1.hpp index 68ada14..d3c60a3 100644 --- a/grk/project/src/ex_9_1.hpp +++ b/grk/project/src/ex_9_1.hpp @@ -244,9 +244,6 @@ void renderEnemies() { } void renderHeartsAndNitro() { - glUseProgram(programSprite); - for (const auto & heart : hearts) { - //if (heart->isAlive()) { //spriteRenderer->DrawSprite(texture::heartTexture, heart->modelMatrix, programSprite); //} @@ -266,7 +263,21 @@ void renderHeartsAndNitro() { ++it; } } - } + + for (auto it = nitros.begin(); it != nitros.end();) { + Nitro* nitro = *it; + if (nitro->isAlive()) { + spriteRenderer->DrawSprite(texture::boosterTexture, nitro->modelMatrix, programSprite); + } + + if (nitro->isCollected) { + spaceship->turboBoost(); + it = nitros.erase(it); + } + else { + ++it; + } + } } @@ -461,13 +472,14 @@ void createEnemies() { enemies.push_back(new Enemy(100.0f, 100.0f, randomModelMatrix, 1.0f, 8.0f)); if (j % 4 == 0) { - hearts.push_back(new Heart(glm::translate(randomModelMatrix, glm::vec3(6.f, 5.f, 25.f)), -5.0f)); + hearts.push_back(new Heart(glm::translate(randomModelMatrix, glm::vec3(6.f, 5.f, 8.f)), -5.0f)); + nitros.push_back(new Nitro(glm::translate(randomModelMatrix, glm::vec3(2.f, -9.f, 3.f)), 10.0f)); } j = j + 1; } hearts.push_back(new Heart(glm::translate(glm::mat4(1.0f), glm::vec3(25.f, 20.f, 25.f)), 10.0f)); - + nitros.push_back(new Nitro(glm::translate(glm::mat4(1.0f), glm::vec3(20.f, 20.f, 25.f)), 10.0f)); //obiekty do ktorych bedzie sprawdzana kolizja dla pociskow enemy gameEntities.push_back(spaceship);