#pragma once

#include "GameKitScene.h"
#include <lvgl.h>
#include <cstdint>

namespace GameKit {

class Loop {
    lv_timer_t* timer = nullptr;
    Scene* scene = nullptr;
    uint32_t periodMs = 0;
    uint32_t lastTickMs = 0;

    static void onTimer(lv_timer_t* timer);

public:
    ~Loop();
    bool start(uint32_t tickMs, Scene* targetScene);
    void stop();
    bool isRunning() const { return timer != nullptr; }
};

} // namespace GameKit
