feat: add Pocket Dungeon game prototype
Main / Build (BookPlayer) (push) Has been cancelled
Main / Build (Brainfuck) (push) Has been cancelled
Main / Build (Breakout) (push) Has been cancelled
Main / Build (Calculator) (push) Has been cancelled
Main / Build (Diceware) (push) Has been cancelled
Main / Build (EpubReader) (push) Has been cancelled
Main / Build (GPIO) (push) Has been cancelled
Main / Build (GraphicsDemo) (push) Has been cancelled
Main / Build (HelloWorld) (push) Has been cancelled
Main / Build (M5UnitTest) (push) Has been cancelled
Main / Build (Magic8Ball) (push) Has been cancelled
Main / Build (MediaKeys) (push) Has been cancelled
Main / Build (MystifyDemo) (push) Has been cancelled
Main / Build (SerialConsole) (push) Has been cancelled
Main / Build (Snake) (push) Has been cancelled
Main / Build (TamaTac) (push) Has been cancelled
Main / Build (TodoList) (push) Has been cancelled
Main / Build (TwoEleven) (push) Has been cancelled
Main / Bundle (push) Has been cancelled

This commit is contained in:
aeroreyna
2026-07-16 22:31:55 -04:00
parent 214287193e
commit d976595879
23 changed files with 862 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#include "GameKitLoop.h"
namespace GameKit {
Loop::~Loop() { stop(); }
bool Loop::start(uint32_t tickMs, Scene* targetScene) {
stop();
if (targetScene == nullptr || tickMs == 0) return false;
scene = targetScene;
periodMs = tickMs;
lastTickMs = lv_tick_get();
timer = lv_timer_create(onTimer, tickMs, this);
return timer != nullptr;
}
void Loop::stop() {
if (timer != nullptr) {
lv_timer_delete(timer);
timer = nullptr;
}
scene = nullptr;
periodMs = 0;
lastTickMs = 0;
}
void Loop::onTimer(lv_timer_t* timer) {
auto* loop = static_cast<Loop*>(lv_timer_get_user_data(timer));
if (loop == nullptr || loop->scene == nullptr) return;
const uint32_t now = lv_tick_get();
uint32_t dt = loop->periodMs;
if (loop->lastTickMs != 0) dt = now - loop->lastTickMs;
loop->lastTickMs = now;
loop->scene->onTick(Tick { dt, now });
loop->scene->render();
}
} // namespace GameKit