Plansza to be continued (WIP)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user