cptx032 / calcium

A ascii/text game library
MIT License
17 stars 2 forks source link

separate sprite class #23

Closed cptx032 closed 6 years ago

cptx032 commented 6 years ago

Today a sprite already has frame animation support, but not all sprites will have animation, so the idea is to create a "flat" sprite, without animation. So will exists a AnimatedSprite to suport animation. Both classes must be "effectable", like screen class today: I must call MyEffect.process(mysprite) and the sprite will be affected just for that frame.

cptx032 commented 6 years ago

I've decided not implement no-animation sprites cause i don't like the way of doing many hierarchical classes, inheriting things, i don't know...look better to me make a single and complete sprite class instead of doing many simple classes inheriting and overriding fields/methods. The idea behind a single-no-animation-sprite was to create an way of do something like the effects in screen: the screen is always cleared, so I can modify it directly. This can't be done with the sprite cause if I modify the 'image' inside animations it will be modified forever, so I need "plot" the original in a temp image and apply effects in this temp image. This is needed because the effect classes if separated from the effected objects them selves. My solution to this was move the effects to inside of sprite, creating a CalciumSprite.effects list that is applied to a copy of image and returned in CalciumSprite.get_pixels method. The image can be modified but must be returned too.