Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (290)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  What exactly defines an entity?  (Read 1198 times)
0 Members and 1 Guest are viewing this topic.
Offline Glass

Senior Newbie





« Posted 2012-03-29 03:11:04 »

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)
Offline Jimmt
« Reply #1 - Posted 2012-03-29 03:16:43 »

An entity for what? "Entity" is kind of a vague term.
Offline theagentd
« Reply #2 - Posted 2012-03-29 03:48:05 »

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.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie
« Reply #3 - Posted 2012-03-29 04:24:30 »

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.

Offline Roquen

JGO Ninja


Medals: 66



« Reply #4 - Posted 2012-03-29 05:47:46 »

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.
Offline Damocles
« Reply #5 - Posted 2012-03-29 05:55:50 »

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.

Offline Glass

Senior Newbie





« Reply #6 - Posted 2012-03-29 06:29:35 »

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?
Offline Roquen

JGO Ninja


Medals: 66



« Reply #7 - Posted 2012-03-29 06:43:48 »

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.
Offline ReBirth
« Reply #8 - Posted 2012-03-29 14:42:01 »

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.

Offline actual

JGO Coder


Medals: 19



« Reply #9 - Posted 2012-03-31 17:37:57 »

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?

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.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
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.





Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (60 views)
2013-05-17 21:29:12

alaslipknot (69 views)
2013-05-16 21:24:48

gouessej (99 views)
2013-05-16 00:53:38

gouessej (98 views)
2013-05-16 00:17:58

theagentd (107 views)
2013-05-15 15:01:13

theagentd (98 views)
2013-05-15 15:00:54

StreetDoggy (144 views)
2013-05-14 15:56:26

kutucuk (167 views)
2013-05-12 17:10:36

kutucuk (166 views)
2013-05-12 15:36:09

UnluckyDevil (175 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.093 seconds with 21 queries.