CCreatureAnimation.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __CCREATUREANIMATION_H__
  2. #define __CCREATUREANIMATION_H__
  3. #include "../global.h"
  4. #include "../CPlayerInterface.h"
  5. #include "../hch/CDefHandler.h"
  6. class CCreatureAnimation : public CIntObject
  7. {
  8. private:
  9. int totalEntries, DEFType, totalBlocks;
  10. int length;
  11. BMPPalette palette[256];
  12. int * RLEntries;
  13. struct SEntry
  14. {
  15. std::string name;
  16. int offset;
  17. int group;
  18. } ;
  19. std::vector<SEntry> SEntries ;
  20. std::string defName, curDir;
  21. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL) const;
  22. void putPixel(
  23. SDL_Surface * dest,
  24. const int & ftcp,
  25. const BMPPalette & color,
  26. const unsigned char & palc,
  27. const bool & yellowBorder
  28. ) const;
  29. ////////////
  30. unsigned char * FDef; //animation raw data
  31. int curFrame; //number of currently displayed frame
  32. unsigned int frames; //number of frames
  33. public:
  34. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  35. int fullWidth, fullHeight; //read-only, please!
  36. CCreatureAnimation(std::string name); //c-tor
  37. ~CCreatureAnimation(); //d-tor
  38. void setType(int type); //sets type of animation and cleares framecount
  39. int getType() const; //returns type of animation
  40. int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
  41. int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, bool IncrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
  42. void incrementFrame();
  43. int getFrame() const;
  44. int framesInGroup(int group) const; //retirns number of fromes in given group
  45. };
  46. #endif // __CCREATUREANIMATION_H__