Implements calling Lua.
This commit is contained in:
70
src/Game.h
Normal file
70
src/Game.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "Frame.h"
|
||||
#include "iDrawable.h"
|
||||
#include "iWritable.h"
|
||||
#include "iScene.h"
|
||||
#include "Logger.h"
|
||||
#include "TickingClock.h"
|
||||
|
||||
|
||||
namespace gj {
|
||||
|
||||
|
||||
class Game : public iDrawable, public iWritable {
|
||||
public:
|
||||
static constexpr size_t kReserveDrawable = 256;
|
||||
static constexpr size_t kReserveWritable = 64;
|
||||
|
||||
struct Param {
|
||||
iAllocator* alloc;
|
||||
const iClock* clock;
|
||||
|
||||
uint32_t w, h;
|
||||
};
|
||||
|
||||
Game() = delete;
|
||||
Game(Game&&) = delete;
|
||||
Game(const Game&) = delete;
|
||||
|
||||
Game& operator=(Game&&) = delete;
|
||||
Game& operator=(const Game&) = delete;
|
||||
|
||||
Game(Param&& p);
|
||||
|
||||
void Update() {
|
||||
clock_.Tick();
|
||||
|
||||
frame_.Clear();
|
||||
UniqPtr<iScene> next = scene_->Update(frame_);
|
||||
if (next) {
|
||||
scene_ = std::move(next);
|
||||
}
|
||||
}
|
||||
|
||||
void Draw(Colorbuffer& fb) const override {
|
||||
frame_.Draw(fb);
|
||||
}
|
||||
void Write(Textbuffer& fb) const override {
|
||||
frame_.Write(fb);
|
||||
logger_.Write(fb);
|
||||
}
|
||||
|
||||
private:
|
||||
iAllocator* alloc_;
|
||||
TickingClock clock_;
|
||||
|
||||
Logger logger_;
|
||||
|
||||
uint32_t w_, h_;
|
||||
Frame frame_;
|
||||
|
||||
UniqPtr<iScene> scene_;
|
||||
};
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user