Currently i'm working on a sprite system which will have frames which make animations.
Usually a sprite contains current position, current frame number to be displayed in the running animation, etc... This is what I mean is STATE.
Let's say there are 100 NPC characters in a game which will have different animations running at any time.If we are maintaining the state in Sprite class, we usually create 100 sprites and draw it as each sprite has its own state.
But I feel the same thing can be done like this, Imagine, position and animation state is separated from the Sprite class.When ever we want to draw we will just set it and draw the frame at certain position.With this approach there is no need to have 100 sprite instances.We can make the exact above situation with one single sprite instance.
For me I feel separating the "state" kills encapsulation.But at the same time it will have a benefit in terms of huge memory!
Please give your Pros/Cons on this kind of approach?