Cyg: Yes, those are the same examples you see everywhere, and to me they don't make sense.
You talk about players and who those players are, I otoh would talk about a generic entity with properties and let those properties dictate what something is supposed to be/do.
So, instead of a player object and a derived alien and robot, I'd have:
With this I could make all kinds of enemies, including your alien and robot *and anything in between*. Moreover, I could decide that, by changing the control field, a player can take over control of an enemy. Also, I could decide that a land animal could suddenly fly away (for instance after applying some magic onto it). To me this is vastly more flexible than a derived system of entities in which some animals can really do nothing else than the stuff they've derived. Apart from this, I simply see no reason to strip apart my type, I see no added readability or improved overview.
Unless I have a completely wrong idea about inheritance of course, but afaik a key element of inheritance was to 'take what you need' and 'leave out what you can'. In my entity case I'd say: I need everything, always. And if you think you should limit your entities to exactly what they should do and nothing more, then I'd say: "why?". Why define a special flying class when this could just be a field upon which you can apply this ability to *all* possible units?
You talk about players and who those players are, I otoh would talk about a generic entity with properties and let those properties dictate what something is supposed to be/do.
So, instead of a player object and a derived alien and robot, I'd have:
Type TEntity Field class ' 0 man, 1 woman, 2 alien, 3 robot, 4 bird, 5 frog, 6 puki Field control ' 0 computer, 1 player Field attack ' 0 attacks human controlled entities, 1 attacks computer controled entities, 2 attacks both Field defence ' 0 flee, 1 counter attack Field detectionwidth ' 0 straight, .., 60 human, .., 360 omni Field movementangle ' 0 any, 1 angles of 45, 2 angles of 90 Field canfly ' 0 no, 1 yes Field canmoveonland ' 0 no, 1 yes Field canswim ' 0 no, 1 yes Field canresurrect ' 0 no, 1 yes Field canbury ' 0 no, 1 yes etc. End Type
With this I could make all kinds of enemies, including your alien and robot *and anything in between*. Moreover, I could decide that, by changing the control field, a player can take over control of an enemy. Also, I could decide that a land animal could suddenly fly away (for instance after applying some magic onto it). To me this is vastly more flexible than a derived system of entities in which some animals can really do nothing else than the stuff they've derived. Apart from this, I simply see no reason to strip apart my type, I see no added readability or improved overview.
Unless I have a completely wrong idea about inheritance of course, but afaik a key element of inheritance was to 'take what you need' and 'leave out what you can'. In my entity case I'd say: I need everything, always. And if you think you should limit your entities to exactly what they should do and nothing more, then I'd say: "why?". Why define a special flying class when this could just be a field upon which you can apply this ability to *all* possible units?