Plansza to be continued (WIP)

This commit is contained in:
2024-12-04 16:04:25 +01:00
parent 72e2116dc7
commit 5eda245ccc
3 changed files with 42 additions and 16 deletions

View File

@@ -10,6 +10,22 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth) {
spawnClock.restart();
}
Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::RenderWindow *mainWindow) {
size.height = windowHeight;
size.width = windowWidth;
window = mainWindow;
meteorTexture1.loadFromFile("../assets/img/meteors/meteor-1.png");
meteorTexture2.loadFromFile("../assets/img/meteors/meteor-2.png");
spawnClock.restart();
}
void Plansza::update() {
}
// Meteor-related niżej
void Plansza::spawn_meteor() {
if (spawnClock.getElapsedTime().asSeconds() > rand() % 10 + 1) { // randomowy spawn meteorytów od 10 do 1 sekundy
if (meteors.size() < 5) { // jeśli jest mniej niż 5 meteorów na planszy
@@ -23,14 +39,6 @@ void Plansza::spawn_meteor() {
}
}
Size Plansza::getSize() {
return size;
}
std::vector<Meteor> &Plansza::getMeteors() {
return meteors;
}
void Plansza::update_meteors() {
// usuwanie meteorów które wyleciały poza ekran
for (auto& meteor : meteors) {
@@ -39,3 +47,14 @@ void Plansza::update_meteors() {
}
}
}
Size Plansza::getSize() {
return size;
}
std::vector<Meteor> &Plansza::getMeteors() {
return meteors;
}