#include "DangerousRacers/Scenes/GameOver.h"

GameOverScene::GameOverScene(SceneManager &_sceneManager) : Scene(_sceneManager, "GameOverScene") {
    if (!wallTileLoaded) {
        wallTileTexture.loadFromFile("assets/wall-tile.png");
        wallTileTexture.setSmooth(false);
        wallTileTexture.setRepeated(true);
        wallTileLoaded = true;
    }

    // 768
    wallTile.setSize({576.f, 768.f});
    wallTile.setTexture(&wallTileTexture);
    wallTile.setTextureRect({0, 0, 576/2, 768/2});
    // wallTile.setFillColor(sf::Color::Red);
}

void GameOverScene::start() {
    Scene::start();

    scoreLabel.setText(
        "Game Over!\n\n"
        "Score: " + std::to_string(sceneManager.getGameManager().getScore()) + "\n"
        "Bubbles Popped: " + std::to_string(sceneManager.getGameManager().getBubblesPopped())
        );
}

void GameOverScene::update(const float deltaTime) {
    Scene::update(deltaTime);
}

void GameOverScene::render(sf::RenderWindow &window) {
    Scene::render(window);
    window.draw(wallTile);
    scoreLabel.render(window);
}

void GameOverScene::eventHandler(sf::Event &event) {
    Scene::eventHandler(event);
}