#include "MainMenuState.h"
#include <iostream>
#include <SDL_image.h>

#include "../Renderer.h"

void MainMenuState::update() {
    // Handle updates like animations if necessary
}

void MainMenuState::init() {
    std::cout << "Main menu state initialized\n";
}

void MainMenuState::handleEvents(SDL_Event& event) {
    if (event.type == SDL_KEYDOWN) {
        switch (event.key.keysym.sym) {
        case SDLK_RETURN:
            std::cout << "Switching to game state\n";
            break;
        case SDLK_ESCAPE:
            std::cout << "Exiting game\n";
            this->changeRoom("exit");
            break;
        default:
            break;
        }
    }

    if (event.type == SDL_MOUSEBUTTONDOWN) {
        this->changeRoom("game");
    }

    if (event.type == SDL_MOUSEMOTION) {
        std::cout << "Mouse moved\n";
    }
}

void MainMenuState::render(SDL_Renderer* renderer) {
    SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
    SDL_RenderClear(renderer);

    SDL_Texture* title = IMG_LoadTexture(renderer, "./res/logo.png");

    drawTexture(renderer, title, WINDOW_WIDTH/2-75, 100, 150, 150);


    SDL_RenderPresent(renderer);
}
