Meteory są w tym samym stanie co w poprzednim commit, tylko, że teraz są zdefiniowane w osobnej klasie "Plansza"

This commit is contained in:
2024-11-20 14:01:43 +01:00
parent cf10a042c0
commit 1cd9f9b950
8 changed files with 84 additions and 39 deletions

View File

@@ -1 +1,29 @@
#include <random>
#include "../headers/Plansza.h"
Plansza::Plansza(int windowHeight, int windowWidth) {
size.height = windowHeight;
size.width = windowWidth;
meteorTexture.loadFromFile("../assets/img/meteor.png");
}
void Plansza::spawn_meteor() {
meteors.emplace_back(random.getRandomNumber(), 100, meteorTexture);
}
Plansza::Size Plansza::getSize() {
return size;
}
std::vector<Meteor> &Plansza::getMeteors() {
return meteors;
}
void Plansza::update_meteors() {
// Remove meteors that are out of bounds
for (auto& meteor : meteors) {
if(meteor.getStatus()) {
meteors.erase(meteors.begin());
}
}
}