Game Circuit Performance and Component Approach

I have an idea to organize a game cycle. I have some doubts about performance. Maybe there are better ways to do something.

You have an array of gaming components. All of them are called to do some things on each iteration of a game cycle. For instance:

GameData data; // shared
app.registerComponent("AI", ComponentAI(data) );
app.registerComponent("Logic", ComponentGameLogic(data) );
app.registerComponent("2d", Component2d(data) );
app.registerComponent("Menu", ComponentMenu(data) )->setActive(false);
//...
while (ok)
{
//...
app.runAllComponents();
//...
}

Benefits:

  • good component-based application, no dependencies, good modularity
  • we can activate / deactivate, dynamically register / unregister components
  • some components can be transparently removed or replaced, and the system will still work because nothing happened (changing 2d to 3d) (teamwork: each programmer creates his own components and does not require code to compile other components)

Doubts:

  • Component:: run()
  • , Component:: run() bool . false, . , .

, ? ?

+3
4

C++ . , . .

, , . , . , , , , .

+5

"" , .

, , ( ) , .. .

, , , - , , "" . , , , , , . , . , , , .

+4

.

, , , , 100 , .

, , , .

+1

, oldschool, , , .

struct GameObject
{
   Ai* ai;
   Transform* transform;
   Renderable* renderable;
   Collision* collision;
   Health* health;
};

: ; "", NULL. ? . (, "AI" ), . , ?

" " , , , . , , , .

, , . , "" . , -. , , , , - , - ?

+1

Source: https://habr.com/ru/post/1742018/


All Articles