Dodano znaczek ladowania ultimate

This commit is contained in:
2025-01-16 23:01:14 +01:00
parent bafab8d75a
commit 3c0cd4b950
8 changed files with 33 additions and 0 deletions

View File

@@ -47,6 +47,8 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
exit(-500);
}
loadUltimateIndicators();
score = 0;
// Wczytywanie czcionki dla licznika punktów
@@ -77,6 +79,29 @@ Plansza::Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::Render
// spawnClock.restart();
}
void Plansza::loadUltimateIndicators() {
const std::string texturePaths[6] = {
"../assets/img/ultimate/ultimate_0.png",
"../assets/img/ultimate/ultimate_20.png",
"../assets/img/ultimate/ultimate_40.png",
"../assets/img/ultimate/ultimate_60.png",
"../assets/img/ultimate/ultimate_80.png",
"../assets/img/ultimate/ultimate_100.png"
};
for (int i = 0; i < 6; ++i) {
if (!ultimateIndicatorTextures[i].loadFromFile(texturePaths[i])) {
std::cerr << "Failed to load ultimate indicator texture: " << texturePaths[i] << std::endl;
exit(-1);
}
sf::Sprite sprite;
sprite.setTexture(ultimateIndicatorTextures[i]);
sprite.setPosition(10, window->getSize().y - 60); // Lewy dolny róg
sprite.setScale(0.7f, 0.7f); // Skalowanie
ultimateIndicators.push_back(sprite);
}
}
// TODO: Refactor tej metody bo rozrosła się za bardzo już
void Plansza::update() {
srand(time(0)); // generacja innego ziarna na podstawie zegara systemowego
@@ -111,6 +136,10 @@ void Plansza::update() {
ship->ultimate_shoot();
}
int indicatorIndex = ultimateCounter / 40;
indicatorIndex = std::min(indicatorIndex, 5); // Zapobiegaj przekroczeniu zakresu
window->draw(ultimateIndicators[indicatorIndex]);
// TODO: Przenieść obiekt dźwięku wewnątrz klasy Bullet
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
ship->shoot();