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 {
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) { }
public void render(Graphics2D g) { } } |
So while your game will have many things that are Entities, nothing in your game will be just an Entity.