#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; OptionalRef mgr; recording_t recording; void update() { ReplayManager & mgr = this->mgr; switch (i++) { default: break; case 10: mgr.record_start(); Log::logf("start"); break; case 60: this->recording = mgr.record_end(); Log::logf("stop"); break; case 70: mgr.play(this->recording); Log::logf("play"); break; case 71: mgr.release(this->recording); Log::logf("end"); break; case 72: Log::logf("exit"); throw; break; }; } }; class TestScene : public Scene { public: using Scene::Scene; void load_scene() { Mediator & m = this->mediator; ComponentManager & mgr = m.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"); Texture texture{"asset/texture/square.png"}; square.add_component(texture, Sprite::Data{ .size = { 0.5, 0.5 }, }); square.add_component().set_script(); GameObject scapegoat = mgr.new_object(""); scapegoat.add_component().set_script(); } string get_name() const { return "scene1"; } }; int main(int argc, char * argv[]) { LoopManager gameloop; gameloop.add_scene(); gameloop.start(); return 0; }