| 1 |
#ifndef HEADER_ANIM_H |
| 2 |
#define HEADER_ANIM_H |
| 3 |
|
| 4 |
class Path; |
| 5 |
class ResImagePack; |
| 6 |
|
| 7 |
#include "ViewEffect.h" |
| 8 |
#include "NoCopy.h" |
| 9 |
#include "V2.h" |
| 10 |
|
| 11 |
#include "SDL.h" |
| 12 |
|
| 13 |
/** |
| 14 |
* Animation sprite. |
| 15 |
*/ |
| 16 |
class Anim : public NoCopy { |
| 17 |
public: |
| 18 |
enum eSide { |
| 19 |
SIDE_LEFT = 0, |
| 20 |
SIDE_RIGHT = 1 |
| 21 |
}; |
| 22 |
private: |
| 23 |
ViewEffect *m_effect; |
| 24 |
V2 m_viewShift; |
| 25 |
ResImagePack *m_animPack[2]; |
| 26 |
std::string m_animName; |
| 27 |
int m_animPhase; |
| 28 |
bool m_run; |
| 29 |
std::string m_specialAnimName; |
| 30 |
int m_specialAnimPhase; |
| 31 |
std::string m_usedPath; |
| 32 |
private: |
| 33 |
void blit(SDL_Surface *screen, SDL_Surface *surface, int x, int y); |
| 34 |
public: |
| 35 |
Anim(); |
| 36 |
virtual ~Anim(); |
| 37 |
|
| 38 |
void drawAt(SDL_Surface *screen, int x, int y, eSide side); |
| 39 |
|
| 40 |
void addAnim(const std::string &name, const Path &picture, |
| 41 |
eSide side=SIDE_LEFT); |
| 42 |
void addAnim(const std::string &name, SDL_Surface *new_image, |
| 43 |
eSide side=SIDE_LEFT); |
| 44 |
void runAnim(const std::string &name, int start_phase=0); |
| 45 |
void setAnim(const std::string &name, int phase); |
| 46 |
void useSpecialAnim(const std::string &name, int phase); |
| 47 |
|
| 48 |
bool isDisintegrated() const { return m_effect->isDisintegrated(); } |
| 49 |
bool isInvisible() const { return m_effect->isInvisible(); } |
| 50 |
void changeEffect(ViewEffect *new_effect); |
| 51 |
void setViewShift(const V2 &shift) { m_viewShift = shift; } |
| 52 |
V2 getViewShift() const { return m_viewShift; }; |
| 53 |
void setEffect(const std::string &effectName); |
| 54 |
|
| 55 |
int countAnimPhases(const std::string &anim, |
| 56 |
eSide side=SIDE_LEFT) const; |
| 57 |
std::string getState() const; |
| 58 |
void restoreState(const std::string &state); |
| 59 |
}; |
| 60 |
|
| 61 |
#endif |