Skip to main content
deleted 18 characters in body
Source Link

In the project I am working on, I recently ran into a problem of software architecture:

I created a base entity class that displays a world object. Then I added functionality for the entity to have a visible piece of text attached to it (I am using SDL2).

That text is part and its supporting variables are part of the entity class. And the render class asks for these variables during the rendering part of the gameloop to render the text.

Got all of that to work. Then I started writing a derived class of the entity class to have an entity that only needs the text stuff.

That is where I started wondering whether it is better to have a text class to be entirely separate from the entity class, because there are situations where I have text that is always there with entities and sometimes I only need text without entities, however the code is almost the same.

Then I read about entity component systems. And I don't get how they work on a high level. How does the "attaching" of components work in the code?

In the project I am working on, I recently ran into a problem of software architecture:

I created a base entity class that displays a world object. Then I added functionality for the entity to have a visible piece of text attached to it (I am using SDL2).

That text is part and its supporting variables are part of the entity class. And the render class asks for these variables during the rendering part of the gameloop to render the text.

Got all of that to work. Then I started writing a derived class of the entity class to have an entity that only needs the text stuff.

That is where I started wondering whether it is better to have a text class to be entirely separate from the entity class, because there are situations where I have text that is always there with entities and sometimes I only need text without entities, however the code is almost the same.

Then I read about entity component systems. And I don't get how they work on a high level. How does the "attaching" of components work in the code?

In the project I am working on, I recently ran into a problem of software architecture:

I created a base entity class that displays a world object. Then I added functionality for the entity to have a visible piece of text attached to it.

That text is part and its supporting variables are part of the entity class. And the render class asks for these variables during the rendering part of the gameloop to render the text.

Got all of that to work. Then I started writing a derived class of the entity class to have an entity that only needs the text stuff.

That is where I started wondering whether it is better to have a text class to be entirely separate from the entity class, because there are situations where I have text that is always there with entities and sometimes I only need text without entities, however the code is almost the same.

Then I read about entity component systems. And I don't get how they work on a high level. How does the "attaching" of components work in the code?

Source Link

How do Entity Component Systems work?

In the project I am working on, I recently ran into a problem of software architecture:

I created a base entity class that displays a world object. Then I added functionality for the entity to have a visible piece of text attached to it (I am using SDL2).

That text is part and its supporting variables are part of the entity class. And the render class asks for these variables during the rendering part of the gameloop to render the text.

Got all of that to work. Then I started writing a derived class of the entity class to have an entity that only needs the text stuff.

That is where I started wondering whether it is better to have a text class to be entirely separate from the entity class, because there are situations where I have text that is always there with entities and sometimes I only need text without entities, however the code is almost the same.

Then I read about entity component systems. And I don't get how they work on a high level. How does the "attaching" of components work in the code?