#include "runtime/loop.h" namespace kumo { Loop::Loop(Clock& clock, LoopConfig config) : timer_(clock), stepper_(config.step, config.max_frame) {} FrameReport Loop::step_frame(Game& game, FrameBuffer& frame) { const int updates = stepper_.advance(timer_.tick()); for (int i = 0; i < updates; ++i) { const Tick tick = {next_tick_index_, stepper_.step()}; game.fixed_update(tick); ++next_tick_index_; } const Fixed alpha = stepper_.alpha_fixed(); game.render(frame, alpha); return {updates, next_tick_index_, alpha}; } void Loop::step_ticks(Game& game, uint64_t count) { for (uint64_t i = 0; i < count; ++i) { const Tick tick = {next_tick_index_, stepper_.step()}; game.fixed_update(tick); ++next_tick_index_; } } } // namespace kumo