#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace crepe; using namespace std; class AnimationScript : public Script { Transform * transform; float t = 0; void init() { transform = &get_component(); } void update() { t += 0.05; transform->position = { sin(t), cos(t) }; } }; class Timeline : public Script { unsigned i = 0; ReplayManager & mgr; recording_t recording; public: Timeline(ReplayManager & mgr) : mgr(mgr) {} void update() { switch (i++) { default: break; case 10: mgr.record_start(); break; case 60: this->recording = mgr.record_end(); break; case 70: mgr.play(this->recording); break; case 71: mgr.release(this->recording); break; case 72: throw; break; }; } }; class TestScene : public Scene { public: using Scene::Scene; void load_scene() { Mediator & mediator = this->mediator; ComponentManager & mgr = mediator.component_manager; GameObject cam = mgr.new_object("cam"); cam.add_component(ivec2{640,480},vec2{3,3}, Camera::Data{ .bg_color = Color::WHITE, }); GameObject square = mgr.new_object("square"); square.add_component( Asset{"asset/texture/square.png"}, Sprite::Data{ .size = { 0.5, 0.5 }, } ); square.add_component().set_script(); GameObject scapegoat = mgr.new_object(""); scapegoat.add_component().set_script(mediator.replay_manager); } string get_name() const { return "scene1"; } }; int main(int argc, char * argv[]) { Config & cfg = Config::get_instance(); cfg.log.level = Log::Level::DEBUG; Engine engine; engine.add_scene(); engine.start(); return 0; }