#include "game.h"
#include <app.hpp>
#include <render/camera.h>

#include "world.hpp"
#include "mainMenu.hpp"

namespace game{

render::Camera gameCamera;

Scene *currentScene = nullptr;
MainMenu *menu = nullptr;
World *world = nullptr;

void init()
{
    gameCamera.screenSize = vec2f(30, 17);
    world = new World();
    menu = new MainMenu();
}

void free()
{
    delete world;
    delete menu;
}

void setState(int state)
{
    if (currentScene) {
        currentScene->Hide();
    }

    switch (state) {
    case 0:
        currentScene = menu;
        break;
    case 1:
        currentScene = world;
        break;
    }

    if (currentScene) {
        currentScene->Show();
    }
}

void update()
{
    if (currentScene) {
        currentScene->Update();
    }
}

void draw()
{
    gameCamera.Bind();
    if (currentScene) {
        currentScene->Render();
    }
}

}

