Meteoryty są spawnowane automatycznie co 1 sekunde, max 5 meteorytów na plansze
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
#include <random>
|
||||
#include <iostream>
|
||||
#include "../headers/Plansza.h"
|
||||
|
||||
Plansza::Plansza(int windowHeight, int windowWidth) {
|
||||
size.height = windowHeight;
|
||||
size.width = windowWidth;
|
||||
meteorsCounter = 0;
|
||||
meteorTexture.loadFromFile("../assets/img/meteor.png");
|
||||
spawnClock.restart();
|
||||
}
|
||||
|
||||
// TODO: Meteory na jednym poziomie ze statkiem
|
||||
// TODO: Kolizje
|
||||
void Plansza::spawn_meteor() {
|
||||
meteors.emplace_back(random.getRandomNumber(), 100, meteorTexture);
|
||||
if (spawnClock.getElapsedTime().asSeconds() > 1.0f) { // spawn co 1 sekunde
|
||||
if (meteors.size() < 5) { // jeśli jest mniej niż 5 meteorów na planszy
|
||||
meteors.emplace_back(random.getRandomNumber(), -100, meteorTexture);
|
||||
}
|
||||
spawnClock.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Plansza::Size Plansza::getSize() {
|
||||
@@ -20,7 +30,7 @@ std::vector<Meteor> &Plansza::getMeteors() {
|
||||
}
|
||||
|
||||
void Plansza::update_meteors() {
|
||||
// Remove meteors that are out of bounds
|
||||
// usuwanie meteorów które wyleciały poza ekran
|
||||
for (auto& meteor : meteors) {
|
||||
if(meteor.getStatus()) {
|
||||
meteors.erase(meteors.begin());
|
||||
|
||||
Reference in New Issue
Block a user