3 分でわかる MitiruEngine
Hello World は 30 行ほど。エンジンを継承して
update() と draw() を書き、engine.run() を呼ぶだけ。
画面はそのまま開きます。
#include <mitiru/Mitiru.hpp>
class MyGame final : public mitiru::Game {
public:
mitiru::Size layout(int w, int h) override { return {w, h}; }
void update(float dt) override { m_t += dt; }
void draw(mitiru::Screen& s) override {
const float w = (float)s.width();
const float h = (float)s.height();
s.drawRect({0, 0, w, h}, {0.62f, 0.80f, 0.93f, 1}); // 空
s.drawCircle({w * 0.5f, h * 0.5f}, 80, {1, 0.9f, 0.4f, 1}); // 太陽
}
private:
float m_t = 0;
};
int main() {
mitiru::Engine engine;
MyGame game;
mitiru::EngineConfig cfg;
cfg.title = "My First Mitiru Game";
cfg.windowWidth = 1280;
cfg.windowHeight = 720;
engine.run(game, cfg);
}エンジンが受け持つ範囲
ジャンルに依存しない共通機能を一式。アクション、RPG、シューティング、シミュレーション、どれでも使い回せます。
-
描画 / シーン
mitiru::Screenでスプライト、図形、テキストを直接描画。SceneRouterでシーン遷移、StateMachineでゲーム内ステートを整理。 -
入力 / ゲームループ
キーボード、マウス、ゲームパッドを
InputMapper経由で扱い、ゲームループはTimer+ 固定タイムステップ。フレーム独立な物理進行が標準。 -
HUD / メニュー (CEF)
HUD やメニューは HTML / CSS で作り、C++ から
state.set()でデータを流し込みます。デザイナーが触れる UI レイヤー。
動くサンプルは サンプル から。