Quote:Original post by Kobalt64
The first scenario I posted is of course a very unlikely one
Correction. It's *very* likely!
Quote:Original post by Kobalt64(You'd have to be crazy to have your animation code all over the jiff like that) but it could happen to someone who's not so good with OO design.
But until you've designed and built an animation system into a game, you won't know the best way to encapsulate the functionality behind and interface. It's a bit like having a PlaySound() function. It's simple to use, easy to understand, and why would anyone want anything more complex?
Well, modifying the pan, pitch, volume as well as applying DSP effects are very soon likely to become requirements, and then you'll quickly realise that the simplified interface is probably not enough. The exact same thing is also true of an animation system.
Quote:Original post by Kobalt64Instead, if they were forced to do things only through IAnimation, it would look more like this:
Which looks far too restrictive to be of much use (if any) in a typical game scenario. The code you posted as an example of what you are trying to avoid, is in actual fact closer to the ideal animation interface than you think. Animation code has a habit of generally being a bit messy (and that's ok), but it has to be open to be able to usefully integrate it with other systems within your game engine, eg
- particle and sound engines to emit dust and footstep sounds when the feet touch the ground
- the user input system that aim's the characters gun
- the collision system so that it knows where the limbs are
- the physics engine to integrate ragdoll physics
The list goes on and on. Sure you can do a number of things to improve encapsulation within the animation system, but I'd recommend refactoring in that encapsulation at a later date when you have a working game. The results will be far better if you attempt it that way.