#include <onidev.h>
#include <onidev/runner.h>
#include "game.h"

int main()
{
    using namespace od;
    
    unsigned size = 12;
    constexpr unsigned CellSize = jewels::Game::CellSize;
    
    Window win(size*CellSize, size*CellSize, "Jewels example");
    View view(0, 0, win.width(), win.height());
    
    GameAssets assets("../assets/");
    jewels::Game game(assets, od::Sizeu(size, size));
    
    Runner::run([&]() -> bool {
        win.ioHandle();
        
        if(!win.open() || keyCheck(vk_escape)) {
            return false;
        }
        
        glClear(GL_COLOR_BUFFER_BIT);
        
        game.step({win.mouse()}, 1.f);
        game.predraw(view);
        game.draw();
        
        if(keyPressed(vk_enter)) {
            game = jewels::Game(assets, od::Sizeu(size, size));
        }
        
        win.screenRefresh();
        return true;
    });
    
    return 0;
}