Is dynamic casting Entities A good design?
Posted
by
Milo
on Game Development
See other posts from Game Development
or by Milo
Published on 2011-06-18T03:05:24Z
Indexed on
2011/06/23
8:30 UTC
Read the original article
Hit count: 414
c++
|architecture
For my game,
Everything inherits from Entity, then other things like Player, PhysicsObject, etc, inherit from Entity. The physics engine sends collision callbacks which has an Entity* to the B that A collided on. Then, lets say A is a Bullet, A tries to cast the entity as a player, if it succeeds, it reduces the player's health.
Is this a good design?
The problem I have with a message system is that I'd need messages for everything, like: entity.sendMessage(SET_PLAYER_HEALTH,16);
So that's why I think casting is cleaner.
© Game Development or respective owner