Search the Community
Showing results for tags 'component system'.
-
Looks like a component of new entity that was created by entity->Instantiate() has a pointer to original entity. Several months it worked fine. Maybe something went wrong when public entity pointer was replaced by GetEntity() method. Steam beta branch. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1200, 800, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetPosition(1, 1, 1); auto component = box->AddComponent<Mover>(); component->rotationspeed.y = 45; auto newBox = box->Instantiate(world, true, true); newBox->SetPosition(2, 2, 2); auto componentTest = newBox->GetComponent<Mover>(); Print("first box pos x:"); Print(box->GetPosition().x); Print(component->GetEntity()->GetPosition().x); Print("second box pos x:"); Print(newBox->GetPosition().x); Print(componentTest->GetEntity()->GetPosition().x); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer, false); } return 0; }
-
During the summer I got more and more entangled game entity classes in my game project, and I really wish I had read this before I started on my journey. I recently stumbled on this article talking about why OOP is not really good for (larger) games to manage game entities, and that introduced me to a better approach. I have yet to test this out in Leadwerks as I am trying to learn more about this before taking a major overhaul. Anyway I hope this could help other people here that might struggle with this. Link to article: http://www.gamedev.net/page/resources/_/technical/game-programming/understanding-component-entity-systems-r3013