mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-12-04 19:23:28 +01:00
port everything over to organizer
This commit is contained in:
parent
edec5e51d3
commit
edcecba2eb
@ -15,10 +15,10 @@ if(NOT MM_HEADLESS)
|
||||
add_subdirectory(sdl_service)
|
||||
add_subdirectory(simple_sdl_renderer)
|
||||
add_subdirectory(opengl_primitives)
|
||||
#add_subdirectory(opengl_renderer)
|
||||
#add_subdirectory(imgui)
|
||||
#add_subdirectory(input)
|
||||
add_subdirectory(opengl_renderer)
|
||||
add_subdirectory(imgui)
|
||||
add_subdirectory(input)
|
||||
add_subdirectory(sound)
|
||||
#add_subdirectory(tilemap)
|
||||
add_subdirectory(tilemap)
|
||||
endif()
|
||||
|
||||
|
@ -91,14 +91,14 @@ void ImGuiService::disable(Engine& engine) {
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
void ImGuiService::imgui_new_frame(Engine& engine) {
|
||||
void ImGuiService::imgui_new_frame(Engine&) {
|
||||
ZoneScopedN("MM::Services::ImGuiService::imgui_new_frame");
|
||||
|
||||
#ifdef MM_OPENGL_3
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
#endif
|
||||
|
||||
ImGui_ImplSDL2_NewFrame(engine.getService<MM::Services::SDLService>().win);
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ target_include_directories(imgui_scene_tools_test PRIVATE ".")
|
||||
|
||||
target_link_libraries(imgui_scene_tools_test
|
||||
engine
|
||||
simple_scene
|
||||
organizer_scene
|
||||
opengl_renderer_s
|
||||
imgui_service
|
||||
imgui_render_task
|
||||
@ -100,7 +100,6 @@ target_include_directories(imgui_text_edit_test PRIVATE ".")
|
||||
|
||||
target_link_libraries(imgui_text_edit_test
|
||||
engine
|
||||
simple_scene
|
||||
opengl_renderer_s
|
||||
imgui_service
|
||||
imgui_render_task
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/imgui_s.hpp>
|
||||
#include <mm/services/imgui_menu_bar.hpp>
|
||||
#include <mm/services/engine_tools.hpp>
|
||||
@ -31,10 +31,10 @@ TEST(imgui_scene_tools, it) {
|
||||
engine.addService<MM::Services::FilesystemService>(argv0, "imgui_scene_tools_test");
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::FilesystemService>());
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
|
||||
engine.addService<MM::Services::ImGuiService>();
|
||||
@ -56,16 +56,12 @@ TEST(imgui_scene_tools, it) {
|
||||
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
|
||||
|
||||
//InitializeYojimbo();
|
||||
|
||||
engine.run();
|
||||
|
||||
|
||||
// TODO: clear asset manager
|
||||
|
||||
sdl_ss.destroyWindow();
|
||||
|
||||
//ShutdownYojimbo();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
#include <mm/services/imgui_s.hpp>
|
||||
#include <mm/services/imgui_menu_bar.hpp>
|
||||
@ -20,8 +19,6 @@
|
||||
#include <mm/imgui/file_text_editor.hpp>
|
||||
#include <mm/imgui/file_shader_editor.hpp>
|
||||
|
||||
#include <mm/services/scene_tools.hpp>
|
||||
|
||||
static char* argv0;
|
||||
|
||||
using namespace entt::literals;
|
||||
@ -55,12 +52,6 @@ TEST(imgui_text_edit, it) {
|
||||
engine.addService<MM::Services::FilesystemService>(argv0, "imgui_text_edit_test");
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::FilesystemService>());
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
|
||||
engine.addService<MM::Services::ImGuiService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiService>());
|
||||
|
||||
@ -70,15 +61,11 @@ TEST(imgui_text_edit, it) {
|
||||
engine.addService<MM::Services::ImGuiEngineTools>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiEngineTools>());
|
||||
|
||||
engine.addService<MM::Services::ImGuiSceneToolsService>();
|
||||
|
||||
auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
|
||||
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
|
||||
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiSceneToolsService>());
|
||||
|
||||
engine.addService<TemplateUpdateMainService>([](MM::Engine& e) {
|
||||
static MM::FileTextEditor fte{e};
|
||||
fte.renderImGui();
|
||||
@ -103,12 +90,6 @@ TEST(imgui_text_edit, shader) {
|
||||
engine.addService<MM::Services::FilesystemService>(argv0, "imgui_text_edit_test");
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::FilesystemService>());
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
|
||||
engine.addService<MM::Services::ImGuiService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiService>());
|
||||
|
||||
@ -118,18 +99,11 @@ TEST(imgui_text_edit, shader) {
|
||||
engine.addService<MM::Services::ImGuiEngineTools>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiEngineTools>());
|
||||
|
||||
engine.addService<MM::Services::ImGuiSceneToolsService>();
|
||||
|
||||
auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
|
||||
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::ImGuiRT>(engine);
|
||||
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiSceneToolsService>());
|
||||
|
||||
//auto& rc = engine.getScene().ctx<MM::OpenGL::RenderController>();
|
||||
//rc.registerRenderer<MM::OpenGL::Renderers::QuadRenderer>();
|
||||
|
||||
MM::FileTextEditor fte{engine};
|
||||
MM::FileShaderEditor fse{engine};
|
||||
engine.addService<TemplateUpdateMainService>([&](MM::Engine&) {
|
||||
@ -142,24 +116,6 @@ TEST(imgui_text_edit, shader) {
|
||||
fse.open("shader/quad_renderer/frag.glsl");
|
||||
|
||||
// TODO: a shader to display plx
|
||||
//{
|
||||
//auto& ecs = engine.getScene();
|
||||
|
||||
//auto& ee = igsts->getEntityEditor();
|
||||
//ee.registerTrivial<MM::OpenGL::Renderers::QuadRenderable>("QuadRenderable");
|
||||
//ee.registerComponentCreateFn(ecs.type<MM::OpenGL::Renderers::QuadRenderable>(),
|
||||
//[](MM::EngineConfig::ECS& ecs, MM::EngineConfig::Entity e) {
|
||||
//auto& r = ecs.assign<MM::OpenGL::Renderers::QuadRenderable>(e);
|
||||
//r._texture = MM::ResourceManager<MM::OpenGL::Texture>::ref().get("default"_hs);
|
||||
//}
|
||||
//);
|
||||
//ee.registerComponentWidgetFn(ecs.type<MM::OpenGL::Renderers::QuadRenderable>(),
|
||||
//[](MM::EngineConfig::ECS& ecs, MM::EngineConfig::Entity e) {
|
||||
//auto& r = ecs.get<MM::OpenGL::Renderers::QuadRenderable>(e);
|
||||
//MM::ImGuiWidgets::Components::QuadRenderable(r);
|
||||
//}
|
||||
//);
|
||||
//}
|
||||
|
||||
engine.run();
|
||||
|
||||
|
@ -31,6 +31,8 @@ target_link_libraries(simple_rect_render_task_test
|
||||
|
||||
simple_velocity_system
|
||||
|
||||
random
|
||||
|
||||
gtest_main
|
||||
)
|
||||
|
||||
@ -100,6 +102,8 @@ target_link_libraries(blur_render_task_test
|
||||
|
||||
simple_velocity_system
|
||||
|
||||
random
|
||||
|
||||
gtest_main
|
||||
)
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/texture_loader.hpp>
|
||||
|
||||
@ -15,15 +16,29 @@
|
||||
|
||||
#include <mm/components/transform2d.hpp>
|
||||
#include <mm/components/color.hpp>
|
||||
#include <mm/components/time_delta.hpp>
|
||||
#include <mm/opengl/render_tasks/spritesheet_renderable.hpp>
|
||||
|
||||
#include <physfs.h>
|
||||
#include "res/textures.zip.h"
|
||||
|
||||
#include <mm/logger.hpp>
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
const char* argv0;
|
||||
|
||||
void update_spritesheet_animation(entt::view<entt::exclude_t<>, MM::OpenGL::SpriteSheetRenderable> view, float& accu, const MM::Components::TimeDelta& td) {
|
||||
accu += td.tickDelta;
|
||||
|
||||
if (accu >= 1.f/10) {
|
||||
accu -= 1.f/10;
|
||||
view.each([](auto& spr) {
|
||||
spr.tile_index = (spr.tile_index+spr.sp.tile_count.x) % (spr.sp.tile_count.x*spr.sp.tile_count.y);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TEST(batched_spritesheet_render_task, it) {
|
||||
MM::Engine engine;
|
||||
|
||||
@ -32,10 +47,10 @@ TEST(batched_spritesheet_render_task, it) {
|
||||
|
||||
sdl_ss.createGLWindow("batched_spritesheet_render_task_test", 1280, 720);
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
@ -54,19 +69,13 @@ TEST(batched_spritesheet_render_task, it) {
|
||||
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::BatchedSpriteSheet>(engine);
|
||||
|
||||
float accu = 0.f;
|
||||
MM::AddSystemToScene(scene, [&accu](auto& scene, float delta) {
|
||||
accu += delta;
|
||||
// setup systems
|
||||
scene.set<float>(0.f); // accu
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&update_spritesheet_animation>("update_spritesheet_animation");
|
||||
|
||||
if (accu >= 1.f/10) {
|
||||
accu -= 1.f/10;
|
||||
scene.template view<MM::OpenGL::SpriteSheetRenderable>()
|
||||
.each([](auto, auto& spr) {
|
||||
spr.tile_index = (spr.tile_index+spr.sp.tile_count.x) % (spr.sp.tile_count.x*spr.sp.tile_count.y);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
auto& rm_t = MM::ResourceManager<MM::OpenGL::Texture>::ref();
|
||||
ASSERT_TRUE(rm_t.load<MM::OpenGL::TextureLoaderFile>("anim_run", engine, "/textures/animation_running-1_ea_0.3.png"));
|
||||
|
@ -4,11 +4,12 @@
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
#include <mm/services/imgui_s.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/clear.hpp>
|
||||
#include <mm/opengl/render_tasks/copy_to_fb.hpp>
|
||||
@ -26,7 +27,7 @@
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <random>
|
||||
#include <mm/random/srng.hpp>
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
@ -40,10 +41,10 @@ TEST(blur_render_task, it) {
|
||||
|
||||
sdl_ss.createGLWindow("blur_render_task_test", 1280, 720);
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
@ -111,9 +112,13 @@ TEST(blur_render_task, it) {
|
||||
|
||||
|
||||
// setup v system
|
||||
MM::AddSystemToScene(scene, MM::Systems::SimpleVelocity);
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&MM::Systems::simple_velocity>("simple_velocity");
|
||||
|
||||
std::mt19937 mt(42);
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
MM::Random::SRNG rng{42};
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
auto e = scene.create();
|
||||
@ -124,14 +129,10 @@ TEST(blur_render_task, it) {
|
||||
auto& v = scene.emplace<MM::Components::Velocity2D>(e);
|
||||
v.rotation = float(i) * 0.3f;
|
||||
|
||||
if (mt() % 2) {
|
||||
if (rng.roll(0.5f)) {
|
||||
auto& col = scene.emplace<MM::Components::Color>(e);
|
||||
auto rc = [&mt]() -> float {
|
||||
return (mt() % 1001) / 1000.f ;
|
||||
};
|
||||
col.color = {rc(),rc(),rc(),1};
|
||||
col.color = {rng.zeroToOne(), rng.zeroToOne(), rng.zeroToOne(), 1.f};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
engine.run();
|
||||
|
@ -4,15 +4,17 @@
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/fast_sky_render_task.hpp>
|
||||
#include <mm/systems/fast_sky_sun_system.hpp>
|
||||
|
||||
#include <mm/opengl/camera_3d.hpp>
|
||||
#include <mm/components/time_delta.hpp>
|
||||
|
||||
const char* argv0;
|
||||
|
||||
@ -24,10 +26,10 @@ TEST(fast_sky_render_task, it) {
|
||||
|
||||
sdl_ss.createGLWindow("fast_sky_render_task_test", 1280, 720);
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
@ -39,7 +41,13 @@ TEST(fast_sky_render_task, it) {
|
||||
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::FastSky>(engine);
|
||||
|
||||
MM::AddSystemToScene(scene, MM::Systems::FastSkySun);
|
||||
// setup systems
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&MM::Systems::fast_sky_sun>("fast_sky_sun");
|
||||
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
|
||||
auto& cam = scene.set<MM::OpenGL::Camera3D>();
|
||||
cam.setPerspective();
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "entt/entity/fwd.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <mm/engine.hpp>
|
||||
@ -9,6 +8,7 @@
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/simple_rect.hpp>
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#include <mm/systems/simple_velocity_system2d.hpp>
|
||||
|
||||
#include <random>
|
||||
#include <mm/random/srng.hpp>
|
||||
|
||||
const char* argv0;
|
||||
|
||||
@ -46,10 +46,12 @@ TEST(simple_rect_render_task, it) {
|
||||
|
||||
// setup v system
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&MM::Systems::simple_velocity>("simple_velocity");
|
||||
|
||||
//MM::AddSystemToScene(scene, MM::Systems::SimpleVelocity);
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
std::mt19937 mt(42);
|
||||
MM::Random::SRNG rng{42};
|
||||
|
||||
for (int y = 0; y < 10; y++) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@ -62,14 +64,10 @@ TEST(simple_rect_render_task, it) {
|
||||
auto& v = scene.emplace<MM::Components::Velocity2D>(e);
|
||||
v.rotation = i * 0.3f;
|
||||
|
||||
if (mt() % 2) {
|
||||
if (rng.roll(0.5f)) {
|
||||
auto& col = scene.emplace<MM::Components::Color>(e);
|
||||
auto rc = [&mt]() -> float {
|
||||
return (mt() % 1001) / 1000.f ;
|
||||
};
|
||||
col.color = {rc(),rc(),rc(),1};
|
||||
col.color = {rng.zeroToOne(), rng.zeroToOne(), rng.zeroToOne(), 1.f};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/simple_sprite.hpp>
|
||||
|
||||
@ -31,10 +32,10 @@ TEST(simple_sprite_render_task, it) {
|
||||
|
||||
sdl_ss.createGLWindow("simple_sprite_render_task_test", 1280, 720);
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
@ -47,7 +48,11 @@ TEST(simple_sprite_render_task, it) {
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleSprite>(engine);
|
||||
|
||||
// setup v system
|
||||
MM::AddSystemToScene(scene, MM::Systems::SimpleVelocity);
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&MM::Systems::simple_velocity>("simple_velocity");
|
||||
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
auto& rm_t = MM::ResourceManager<MM::OpenGL::Texture>::ref();
|
||||
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/texture_loader.hpp>
|
||||
|
||||
@ -15,6 +16,7 @@
|
||||
|
||||
#include <mm/components/transform2d.hpp>
|
||||
#include <mm/components/color.hpp>
|
||||
#include <mm/components/time_delta.hpp>
|
||||
#include <mm/opengl/render_tasks/spritesheet_renderable.hpp>
|
||||
|
||||
#include <physfs.h>
|
||||
@ -22,6 +24,17 @@
|
||||
|
||||
using namespace entt::literals;
|
||||
|
||||
void update_spritesheet_animation(entt::view<entt::exclude_t<>, MM::OpenGL::SpriteSheetRenderable> view, float& accu, const MM::Components::TimeDelta& td) {
|
||||
accu += td.tickDelta;
|
||||
|
||||
if (accu >= 1.f/10) {
|
||||
accu -= 1.f/10;
|
||||
view.each([](auto& spr) {
|
||||
spr.tile_index = (spr.tile_index+spr.sp.tile_count.x) % (spr.sp.tile_count.x*spr.sp.tile_count.y);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TEST(simple_spritesheet_render_task, it) {
|
||||
MM::Engine engine;
|
||||
|
||||
@ -30,10 +43,10 @@ TEST(simple_spritesheet_render_task, it) {
|
||||
|
||||
sdl_ss.createGLWindow("simple_spritesheet_render_task_test", 1280, 720);
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
@ -52,19 +65,13 @@ TEST(simple_spritesheet_render_task, it) {
|
||||
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleSpriteSheet>(engine);
|
||||
|
||||
float accu = 0.f;
|
||||
MM::AddSystemToScene(scene, [&accu](auto& scene, float delta) {
|
||||
accu += delta;
|
||||
// setup systems
|
||||
scene.set<float>(0.f); // accu
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&update_spritesheet_animation>("update_spritesheet_animation");
|
||||
|
||||
if (accu >= 1.f/10) {
|
||||
accu -= 1.f/10;
|
||||
scene.template view<MM::OpenGL::SpriteSheetRenderable>()
|
||||
.each([](auto, auto& spr) {
|
||||
spr.tile_index = (spr.tile_index+spr.sp.tile_count.x) % (spr.sp.tile_count.x*spr.sp.tile_count.y);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
auto& rm_t = MM::ResourceManager<MM::OpenGL::Texture>::ref();
|
||||
ASSERT_TRUE(rm_t.load<MM::OpenGL::TextureLoaderFile>("anim_run", engine, "/textures/animation_running-1_ea_0.3.png"));
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
@ -27,10 +27,10 @@ TEST(tilemap_render_task_test, it) {
|
||||
|
||||
sdl_ss.createGLWindow("tilemap_render_task_test", 1280, 720);
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
|
@ -7,6 +7,10 @@ namespace MM::Random {
|
||||
|
||||
// Seeded (Pseudo-) Random Number Generator
|
||||
struct SRNG {
|
||||
// make shuffle compat
|
||||
// TODO: add more type info
|
||||
using result_type = uint32_t;
|
||||
|
||||
uint32_t seed = 1337;
|
||||
int32_t pos = 0;
|
||||
|
||||
|
@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.2)
|
||||
project(screens CXX)
|
||||
|
||||
if(NOT MM_HEADLESS)
|
||||
#add_subdirectory(mm_logo)
|
||||
add_subdirectory(mm_logo)
|
||||
endif()
|
||||
|
||||
|
@ -21,6 +21,8 @@ target_link_libraries(mm_logo_screen
|
||||
simple_sprite_render_task
|
||||
|
||||
common_components
|
||||
|
||||
random
|
||||
)
|
||||
|
||||
#if (BUILD_TESTING)
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/simple_sprite.hpp>
|
||||
|
||||
@ -14,12 +15,60 @@
|
||||
|
||||
#include <mm/components/transform2d.hpp>
|
||||
#include <mm/components/color.hpp>
|
||||
#include <mm/components/time_delta.hpp>
|
||||
#include <mm/opengl/components/texture.hpp>
|
||||
|
||||
#include <mm/random/srng.hpp>
|
||||
#include <random>
|
||||
|
||||
namespace MM::Screens {
|
||||
|
||||
namespace Components {
|
||||
|
||||
struct screen_timer {
|
||||
float accumulator = 0.f;
|
||||
float duration = 0.f;
|
||||
std::string next_screen;
|
||||
};
|
||||
|
||||
struct easing {
|
||||
glm::vec2 start{0.f, 0.f};
|
||||
glm::vec2 end{0.f, 0.f};
|
||||
|
||||
float accumulator = 0.f;
|
||||
float duration = 1.f;
|
||||
};
|
||||
|
||||
} // Components
|
||||
|
||||
namespace Systems {
|
||||
|
||||
void screen_timer_system(Components::screen_timer& sc_timer, const MM::Components::TimeDelta& td, const MM::Engine* engine) {
|
||||
sc_timer.accumulator += td.tickDelta;
|
||||
if (sc_timer.accumulator >= sc_timer.duration) {
|
||||
engine->getService<MM::Services::ScreenDirector>().queueChangeScreenTo(sc_timer.next_screen);
|
||||
}
|
||||
}
|
||||
|
||||
// elastic scale easing
|
||||
void elasic_scale_easing(entt::view<entt::exclude_t<>, MM::Components::Transform2D, Components::easing> view, const MM::Components::TimeDelta& td) {
|
||||
view.each([&td](auto& t, auto& easing_comp) {
|
||||
easing_comp.accumulator += td.tickDelta;
|
||||
|
||||
// taken from https://github.com/warrenm/AHEasing
|
||||
// licensed under WTFPL
|
||||
auto elasticOut = [](float x) -> float {
|
||||
return glm::sin(-13.f * glm::half_pi<float>() * (x + 1.f)) * glm::pow(2.f, -10.f * x) + 1.f;
|
||||
};
|
||||
|
||||
t.scale.x = glm::mix(easing_comp.start.x, easing_comp.end.x, elasticOut(easing_comp.accumulator / easing_comp.duration));
|
||||
t.scale.y = glm::mix(easing_comp.start.y, easing_comp.end.y, elasticOut(easing_comp.accumulator / easing_comp.duration));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
} // Systems
|
||||
|
||||
#include "../res/mush_machine_logo_1.svg.png.h"
|
||||
|
||||
void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& screen,
|
||||
@ -27,14 +76,14 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc
|
||||
using namespace entt::literals;
|
||||
|
||||
screen.start_enable.push_back(engine.type<MM::Services::OpenGLRenderer>());
|
||||
screen.start_enable.push_back(engine.type<MM::Services::SimpleSceneService>());
|
||||
screen.start_enable.push_back(engine.type<MM::Services::OrganizerSceneService>());
|
||||
|
||||
screen.start_provide.push_back({engine.type<MM::Services::SceneServiceInterface>(), engine.type<MM::Services::SimpleSceneService>()});
|
||||
screen.start_provide.push_back({engine.type<MM::Services::SceneServiceInterface>(), engine.type<MM::Services::OrganizerSceneService>()});
|
||||
|
||||
screen.end_disable.push_back(engine.type<MM::Services::SimpleSceneService>());
|
||||
screen.end_disable.push_back(engine.type<MM::Services::OrganizerSceneService>());
|
||||
|
||||
screen.start_fn = [anim_duration, screen_duration, next_screen](MM::Engine& engine) {
|
||||
auto& rs = engine.getService<MM::Services::OpenGLRenderer>();
|
||||
screen.start_fn = [anim_duration, screen_duration, next_screen](MM::Engine& _engine) {
|
||||
auto& rs = _engine.getService<MM::Services::OpenGLRenderer>();
|
||||
|
||||
//rss->renderers.clear();
|
||||
|
||||
@ -47,7 +96,7 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleSprite>(engine);
|
||||
rs.addRenderTask<MM::OpenGL::RenderTasks::SimpleSprite>(_engine);
|
||||
}
|
||||
|
||||
// =================================================
|
||||
@ -59,58 +108,18 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc
|
||||
|
||||
// =================================================
|
||||
|
||||
engine.getService<MM::Services::SceneServiceInterface>().changeSceneNow(std::make_unique<MM::Scene>());
|
||||
auto& scene = engine.getService<MM::Services::SceneServiceInterface>().getScene();
|
||||
auto new_scene = std::make_unique<MM::Scene>();
|
||||
auto& scene = *new_scene;
|
||||
|
||||
scene.ctx_or_set<MM::Engine*>(&engine);
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
|
||||
struct easing {
|
||||
glm::vec2 start{0.f, 0.f};
|
||||
glm::vec2 end{0.f, 0.f};
|
||||
scene.set<MM::Engine*>(&_engine);
|
||||
|
||||
float accumulator = 0.f;
|
||||
float duration = 1.f;
|
||||
};
|
||||
scene.set<Components::screen_timer>(0.f, screen_duration, next_screen);
|
||||
|
||||
struct screen_timer {
|
||||
float accumulator = 0.f;
|
||||
};
|
||||
org.emplace<&Systems::screen_timer_system>("screen_timer_system");
|
||||
|
||||
MM::AddSystemToScene(scene, [screen_duration, next_screen](MM::Scene& scene, float delta) {
|
||||
auto& sc_timer = scene.ctx<screen_timer>();
|
||||
sc_timer.accumulator += delta;
|
||||
|
||||
if (sc_timer.accumulator >= screen_duration) {
|
||||
scene.ctx<MM::Engine*>()->getService<MM::Services::ScreenDirector>().queueChangeScreenTo(next_screen);
|
||||
}
|
||||
});
|
||||
scene.set<screen_timer>();
|
||||
|
||||
// elastic scale easing
|
||||
MM::AddSystemToScene(scene, [](MM::Scene& scene, float delta) {
|
||||
auto view = scene.view<MM::Components::Transform2D, easing>();
|
||||
|
||||
for (auto& e : view) {
|
||||
auto& t = view.get<MM::Components::Transform2D>(e);
|
||||
auto& easing_comp = view.get<easing>(e);
|
||||
easing_comp.accumulator += delta;
|
||||
|
||||
//auto elasticOut = [](float x) -> float {
|
||||
//const float c4 = (2.f * glm::pi<float>()) / 3.f;
|
||||
//return x <= 0.f ? 0.f : x >= 1.f ? 1.f // limit output to [0,1]
|
||||
//: glm::pow(2.f, -10.f * x) * glm::sin((x * 10.f - 0.75f) * c4) + 1.f;
|
||||
//};
|
||||
// taken from https://github.com/warrenm/AHEasing
|
||||
// licensed under WTFPL
|
||||
auto elasticOut = [](float x) -> float {
|
||||
return glm::sin(-13.f * glm::half_pi<float>() * (x + 1.f)) * glm::pow(2.f, -10.f * x) + 1.f;
|
||||
};
|
||||
|
||||
t.scale.x = glm::mix(easing_comp.start.x, easing_comp.end.x, elasticOut(easing_comp.accumulator / easing_comp.duration));
|
||||
t.scale.y = glm::mix(easing_comp.start.y, easing_comp.end.y, elasticOut(easing_comp.accumulator / easing_comp.duration));
|
||||
|
||||
}
|
||||
});
|
||||
org.emplace<&Systems::elasic_scale_easing>("elasic_scale_easing");
|
||||
|
||||
auto& cam = scene.set<MM::OpenGL::Camera3D>();
|
||||
cam.horizontalViewPortSize = 89.f;
|
||||
@ -122,7 +131,7 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc
|
||||
auto& t = scene.emplace<MM::Components::Transform2D>(e_logo);
|
||||
t.scale = {0,0};
|
||||
|
||||
auto& easing_comp = scene.emplace<easing>(e_logo);
|
||||
auto& easing_comp = scene.emplace<Components::easing>(e_logo);
|
||||
easing_comp.start = {0.f, 0.f};
|
||||
easing_comp.end = {50.f * 1.12609649122807017543f, 50.f};
|
||||
easing_comp.duration = anim_duration;
|
||||
@ -152,19 +161,21 @@ void create_mm_logo(MM::Engine& engine, MM::Services::ScreenDirector::Screen& sc
|
||||
1.f,
|
||||
};
|
||||
|
||||
std::mt19937_64 mt{std::random_device{}()};
|
||||
//std::mt19937_64 mt{std::random_device{}()};
|
||||
MM::Random::SRNG rng{std::random_device{}(), 0};
|
||||
|
||||
std::vector<glm::vec3> colors {color1, color2, color3};
|
||||
std::shuffle(colors.begin(), colors.end(), mt);
|
||||
std::shuffle(colors.begin(), colors.end(), rng);
|
||||
|
||||
auto& col = scene.emplace<MM::Components::Color>(e_logo);
|
||||
col.color = {colors.front(), 1.f};
|
||||
}
|
||||
|
||||
_engine.getService<MM::Services::SceneServiceInterface>().changeSceneNow(std::move(new_scene));
|
||||
};
|
||||
|
||||
screen.end_fn = [](MM::Engine& engine) {
|
||||
engine.getService<MM::Services::SceneServiceInterface>().changeSceneNow(std::make_unique<MM::Scene>());
|
||||
screen.end_fn = [](MM::Engine& _engine) {
|
||||
_engine.getService<MM::Services::SceneServiceInterface>().changeSceneNow(std::make_unique<MM::Scene>());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ project(systems CXX)
|
||||
add_subdirectory(simple_velocity)
|
||||
|
||||
if(NOT MM_HEADLESS)
|
||||
#add_subdirectory(player_velocity)
|
||||
#add_subdirectory(fast_sky_sun)
|
||||
add_subdirectory(player_velocity)
|
||||
add_subdirectory(fast_sky_sun)
|
||||
endif()
|
||||
|
||||
|
@ -11,6 +11,7 @@ target_include_directories(fast_sky_sun_system PUBLIC "${CMAKE_CURRENT_SOURCE_DI
|
||||
target_link_libraries(fast_sky_sun_system
|
||||
engine
|
||||
fast_sky_render_task
|
||||
common_components
|
||||
)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include <mm/services/scene_service_interface.hpp>
|
||||
|
||||
#include <mm/components/time_delta.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/fast_sky_render_task.hpp>
|
||||
@ -10,10 +12,8 @@
|
||||
|
||||
namespace MM::Systems {
|
||||
|
||||
void FastSkySun(Scene& scene, float delta) {
|
||||
auto& sky_ctx = scene.ctx<MM::OpenGL::RenderTasks::FastSkyContext>();
|
||||
|
||||
sky_ctx.time += delta * 0.2f;
|
||||
void fast_sky_sun(MM::OpenGL::RenderTasks::FastSkyContext& sky_ctx, const MM::Components::TimeDelta& delta) {
|
||||
sky_ctx.time += delta.tickDelta * 0.2f;
|
||||
|
||||
sky_ctx.fsun.y = glm::sin(sky_ctx.time * 0.01f);
|
||||
sky_ctx.fsun.z = glm::cos(sky_ctx.time * 0.01f);
|
||||
|
@ -2,10 +2,18 @@
|
||||
|
||||
#include <mm/engine_fwd.hpp>
|
||||
|
||||
// fwd
|
||||
namespace MM::OpenGL::RenderTasks {
|
||||
struct FastSkyContext;
|
||||
}
|
||||
namespace MM::Components {
|
||||
struct TimeDelta;
|
||||
}
|
||||
|
||||
namespace MM::Systems {
|
||||
|
||||
// this system updates time and sun depending on time with the time delta
|
||||
void FastSkySun(Scene& scene, float delta);
|
||||
void fast_sky_sun(MM::OpenGL::RenderTasks::FastSkyContext& c, const MM::Components::TimeDelta& delta);
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
@ -2,34 +2,28 @@
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
|
||||
#include <mm/services/input_service.hpp>
|
||||
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
namespace MM::Systems {
|
||||
void PlayerVelocity2D(Scene& scene, float) {
|
||||
ZoneScopedN("MM::Systems::PlayerVelocity2D");
|
||||
|
||||
MM::Engine* engine_ptr = scene.ctx<MM::Engine*>();
|
||||
auto& input_ss = engine_ptr->getService<MM::Services::InputService>();
|
||||
void player_velocity2d(entt::view<entt::exclude_t<>, MM::Input::PlayerID, MM::Components::Velocity2D> view, const MM::Engine* engine) {
|
||||
ZoneScopedN("MM::Systems::PlayerVelocity2D");
|
||||
|
||||
scene.view<MM::Input::PlayerID, MM::Components::Velocity2D>().each(
|
||||
[&input_ss](const MM::Input::PlayerID p_id, MM::Components::Velocity2D& v) {
|
||||
//const float movement_speed = 8.f; // apply via post processing
|
||||
auto& input_ss = engine->getService<MM::Services::InputService>();
|
||||
|
||||
auto vec_force = input_ss.getMoveForce(p_id);
|
||||
view.each([&input_ss](const MM::Input::PlayerID p_id, MM::Components::Velocity2D& v) {
|
||||
//const float movement_speed = 8.f; // apply via post processing
|
||||
|
||||
if (vec_force >= 0.01f) {
|
||||
v.velocity = input_ss.getMoveVec(p_id);
|
||||
v.velocity *= vec_force;
|
||||
//v.velocity *= movement_speed;
|
||||
} else {
|
||||
v.velocity = {0.f, 0.f};
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
auto vec_force = input_ss.getMoveForce(p_id);
|
||||
|
||||
if (vec_force >= 0.01f) {
|
||||
v.velocity = input_ss.getMoveVec(p_id);
|
||||
//v.velocity *= vec_force;
|
||||
} else {
|
||||
v.velocity = {0.f, 0.f};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
//#include <mm/services/scene_service_interface.hpp>
|
||||
#include <mm/engine_fwd.hpp>
|
||||
#include <entt/entity/utility.hpp>
|
||||
#include <mm/services/input_service.hpp>
|
||||
#include <mm/components/velocity2d.hpp>
|
||||
|
||||
namespace MM::Systems {
|
||||
|
||||
// this system transforms the input from the input_ss into velocity
|
||||
// uses Components::Velocity2D, PlayerID
|
||||
void PlayerVelocity2D(Scene& scene, float delta);
|
||||
// this system transforms the input from the input_service into velocity
|
||||
void player_velocity2d(entt::view<entt::exclude_t<>, MM::Input::PlayerID, MM::Components::Velocity2D> view, const MM::Engine* engine);
|
||||
|
||||
} // MM::Systems
|
||||
|
||||
|
@ -6,7 +6,7 @@ target_include_directories(player_velocity_test PRIVATE ".")
|
||||
|
||||
target_link_libraries(player_velocity_test
|
||||
player_velocity_system
|
||||
simple_scene
|
||||
organizer_scene
|
||||
gtest_main
|
||||
)
|
||||
|
||||
|
@ -3,9 +3,10 @@
|
||||
#include <mm/engine.hpp>
|
||||
#include <mm/services/sdl_service.hpp>
|
||||
#include <mm/services/input_service.hpp>
|
||||
#include <mm/services/simple_scene.hpp>
|
||||
#include <mm/services/organizer_scene.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/organizer.hpp>
|
||||
|
||||
#include <mm/systems/player_velocity2d_system.hpp>
|
||||
|
||||
@ -19,16 +20,21 @@ TEST(player_velocity, basic_run) {
|
||||
engine.addService<MM::Services::InputService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::InputService>());
|
||||
|
||||
engine.addService<MM::Services::SimpleSceneService>(delta);
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSceneService>());
|
||||
engine.addService<MM::Services::OrganizerSceneService>(delta);
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
|
||||
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::SimpleSceneService>();
|
||||
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
|
||||
ASSERT_TRUE(provide_ret);
|
||||
|
||||
auto& scene = engine.tryService<MM::Services::SceneServiceInterface>()->getScene();
|
||||
|
||||
// setup v system
|
||||
MM::AddSystemToScene(scene, MM::Systems::PlayerVelocity2D);
|
||||
auto& org = scene.set<entt::organizer>();
|
||||
org.emplace<&MM::Systems::player_velocity2d>("player_velocity2d");
|
||||
|
||||
// HACK: instead you would switch to this scene
|
||||
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
|
||||
|
||||
|
||||
//auto [e, t, v] = scene.create<MM::Components::Transform, MM::Components::Velocity>();
|
||||
//t.position = { 0.f, 0.f };
|
||||
|
Loading…
Reference in New Issue
Block a user