Dodano podstawowy licznik

This commit is contained in:
2024-12-10 20:30:31 +01:00
parent e2e44ff1ba
commit 74c739a09e
2 changed files with 25 additions and 0 deletions

View File

@@ -12,6 +12,13 @@ ship(static_cast<int>(mainWindow->getSize().x) / 2, static_cast<int>(mainWindow-
size.height = static_cast<int>(windowHeight);
size.width = static_cast<int>(windowWidth);
score = 0;
if (!font.loadFromFile("../assets/fonts/arial.ttf")) {
std::cerr << "Error loading font\n";
exit(-500);
}
ship.setMovingSpeed(8);
ship.setFirerate(200);
@@ -157,6 +164,7 @@ void Plansza::update() {
++meteorIt;
}
}
update_score();
}
// Meteor-related niżej
@@ -191,5 +199,18 @@ std::vector<Meteor> &Plansza::getMeteors() {
return meteors;
}
// TODO: naliczanie punktów za zabicie wrogów
void Plansza::update_score() {
if (scoreClock.getElapsedTime().asMilliseconds() > 500) {
score++;
scoreClock.restart();
}
sf::Text text(std::to_string(score), font, 24);
text.setFillColor(sf::Color::White);
text.setPosition(25, 25);
window->draw(text);
}