What exactly defines an entity?

What makes an entity an entity, what special features does it have? What do entities do?

EDIT: entity as in the ones commonly used in games for a superclass(i think thats the right term)

An entity for what? “Entity” is kind of a vague term.

Google “definition of life”! xD

An entity usually contains all the variables and functions that are shared by all objects in the game, for example position and an abstract draw() function, e.t.c.

It’s as vague a word as “Thing”. In fact that’s exactly what it means, it comes from the Latin word for “thing” (entis). An Entity is a Thing, and outside one specific context (below) it doesn’t mean anything more than that.

You’ll sometimes hear about “Entity Systems” or “Entity Component Systems”, and that’s more to do with an Entity-Relational model that decomposes objects into much finer-grained related components that can be assembled in ways that’s too inconvenient for a static type system. Views on entity systems range from “Silver Bullet” to “Tits on a Bull”.

In these systems, an Entity is a collection of components, but is only used for its identity to project its related components from, while separate systems act on the “vertical” collections of components. Think of each entity as a row in a database and components as columns, and that’s where you get the notion of “verticality” from.

Yeah there is not solid definition as the notion will vary programmer to programmer and project to project. Generally an “entity” or a “game object” are two different terms for the same thing. I’ll refer to the stuff I do as an “Entity System”, although I don’t use a component model and I think of it as the logically block that separates engine side activities from the scripting/world building side.

The entity is one of the upper squares in your Class-UML.
The things lower connected to it are specific children of it. :wink:

I would define entity as something that is contained in a level. And can change.
And is not an Asset or a pure Metaobject.

So it’s a general thing, without much of a stone-set definition. Besides a draw function, and its position in the screen, what else does the entity superclass need in it? Not all the entities will move, so you can’t have moving functions, and health/stamina seem too specific too. What else could you possibly put in there that defines every single ‘something’ in the game?

Without a specific game design…it’s hard give any specifics. And with a given design, you’d get a lot of disagreement about what route to take. Some points that most of us would probably agree on is: use a data driven model and the more complex the needed interactions are use some method of “design by composition” instead of “design by inheritance”. So if you’re thinking about “Chair” or “PotionOfSuperDuperHealing” classes…you’re heading in the wrong direction.

Entity in programming, is the result of combination between fields (attributes) and methods (behaviours) which are showing how it will interact, how important it is, etc.

Although it is less fashionable as of late you can use inheritance. So your GameEntity is basic and only provide fields or method hooks that are general to all.

abstract class GameEntity {

   public int id;

   public Entity(int id) {
      this.id = id;
   }

   public void render(Graphics2D g)

   public void update(long frameTime)

}

Then your specific entities would inherit from GameEntity and provide more specific behavior

public class Tank extends GameEntity {

   // Tank specific fields
  int ammo = 100;
  int damage;
  int speed;

  public Tank(int id, int damage, int speed) {
     this.damage = damage;
     this.speed = speed;
 }

 public void update(long frameTime) {
      // Put in your tank specific update code
 }


 public void render(Graphics2D g) {
      // Put in your code to draw a tank
  }
}

So while your game will have many things that are Entities, nothing in your game will be just an Entity.