So everywhere I look I see things about entities, what are they? What do they do? How are they used?
Thanks
So everywhere I look I see things about entities, what are they? What do they do? How are they used?
Thanks
Pretty much like FLeBlanc said, an entity is anything that may exist in a game world, be it the player character, a projectile, a trigger (as in event trigger, not a gun trigger), etc.
One thing to note is that normally when we hear game world one usually thinks about the visible things (geometry), but an entity isn't necessarily something that needs to be rendered (although there may be people who only call entities to the things that need to be rendered).
As previous posts suggested an entity is pretty much everything. It's for sure to complicated to explain in one post, articles are more suited for the job. I'm not gonna try explain to you what an entity is, but I want to give you an advice - everyone has different opinions about what an entity is, why you need one, how it is implemented etc etc. Everything you read about the matter should be read with a pinch of salt (and in some cases a handful of salt!). You can't read an article and assume what that article explained to you is true in another article, that I learned the hard way.
The most common approaches of Entity Systems have unofficial labels that you will come across whence you lurk more... People talking about, for example, T-Machine ES (Entity System) are generally talking about the same approach of entity system. You might want to memorize the unofficial labels names each type of ES has been given and what's special about that entity system, it will help you from mixing up the different concepts of different entity systems.
Here's some helpful articles that helped me understand ES:
http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/ (T-machine entity system)
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ (Objects (entities) as pure aggregation)
While it might be mind-boggling to read get into ES-concept, it is well worth it. I personally feel Entity Systems give the programmer much more freedom and it becomes easier to structure your game. Decoupling is very easy to manage.
I can answer your questions very briefly how I did it:
1. An entitiy is an integer, GUID (Globally Unique IDentifier), that is used to index arrays for it's components (data-collections). In my implementation it is NOT a class.
2. The entity GUID index arrays to access it's components.
3. Systems has access to relevant components. My moveSystem have an update function which can iterate through all positionComponents and velocityComponents and do the logic upon these, altering the component values.
As a few others have pointed out entities are basically your "dynamic" objects in a game world. If you use something like an old n64 game like banjo kazooie, the thing like enemies, friendly npcs, collectible items and other things would generally be considered "entities." Sometimes entities are used as a phrase for component based systems but in the general scheme of game development entities are just all that stuff you interact with that isn't part of the game world geometry.