#include "DangerousRacers/Scenes/TutorialOver.h"

#include "SFML/Window/Event.hpp"
#include "SFML/Window/Keyboard.hpp"

TutorialOverScene::TutorialOverScene(SceneManager &_sceneManager) : Scene(_sceneManager, "TutorialOverScene") {
    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 TutorialOverScene::start() {
    Scene::start();
}

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

void TutorialOverScene::render(sf::RenderWindow &window) {
    Scene::render(window);
    window.draw(wallTile);
    gameOverLabel.render(window);
    returnButton.render(window);
}

void TutorialOverScene::eventHandler(sf::Event &event) {
    Scene::eventHandler(event);
    returnButton.eventHandler(event);

    if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
        this->sceneManager.changeScene("MainMenu");
    }
}