00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef INCL_ANIMATE
00026 #define INCL_ANIMATE 1
00027
00028 #include "iregobjs.h"
00029
00030
00031
00032
00033 class Animator : public Time_sensitive, public Game_singletons
00034 {
00035 protected:
00036 Game_object *obj;
00037 unsigned char deltax, deltay;
00038
00039 bool animating;
00040 int sfxnum;
00041 void start_animation();
00042 public:
00043 Animator(Game_object *o, int snum = -1)
00044 : obj(o), deltax(0), deltay(0), animating(false), sfxnum(snum)
00045 { }
00046 static Animator *create(Game_object *ob);
00047 ~Animator();
00048 void want_animation()
00049 {
00050 if (!animating)
00051 start_animation();
00052 }
00053 int get_deltax()
00054 { return deltax; }
00055 int get_deltay()
00056 { return deltay; }
00057 virtual int get_framenum();
00058 };
00059
00060
00061
00062
00063 class Frame_animator : public Animator
00064 {
00065 unsigned char first_frame;
00066 unsigned char frames;
00067 unsigned int created;
00068 unsigned int delay;
00069 unsigned short last_shape;
00070 unsigned short last_frame;
00071 enum
00072 {
00073 FA_LOOPING = 0,
00074 FA_SUNDIAL = 1,
00075 FA_ENERGY_FIELD = 2
00076 } type;
00077 void Initialize();
00078 public:
00079 Frame_animator(Game_object *o);
00080 virtual int get_framenum();
00081
00082 virtual void handle_event(unsigned long time, long udata);
00083 };
00084
00085
00086
00087
00088 class Sfx_animator : public Animator
00089 {
00090 public:
00091 Sfx_animator(Game_object *o);
00092
00093 virtual void handle_event(unsigned long time, long udata);
00094 };
00095
00096
00097
00098
00099 class Field_frame_animator : public Animator
00100 {
00101 unsigned char frames;
00102 unsigned char recycle;
00103 bool activated;
00104 public:
00105 friend class Field_object;
00106 Field_frame_animator(Game_object *o, int rcy);
00107
00108 virtual void handle_event(unsigned long time, long udata);
00109 };
00110
00111
00112
00113
00114 class Wiggle_animator : public Animator
00115 {
00116 public:
00117 Wiggle_animator(Game_object *o) : Animator(o)
00118 { }
00119
00120 virtual void handle_event(unsigned long time, long udata);
00121 };
00122
00123
00124
00125
00126
00127 class Animated_object : public Terrain_game_object
00128 {
00129 Animator *animator;
00130 public:
00131 Animated_object(int shapenum, int framenum, unsigned int tilex,
00132 unsigned int tiley, unsigned int lft = 0);
00133 virtual ~Animated_object();
00134
00135 virtual void paint();
00136
00137
00138 virtual Tile_coord get_original_tile_coord() const
00139 { return get_tile() +
00140 Tile_coord(-animator->get_deltax(),
00141 -animator->get_deltay(), 0); }
00142 };
00143
00144
00145
00146
00147
00148 class Animated_ireg_object : public Ireg_game_object
00149 {
00150 Animator *animator;
00151 public:
00152 Animated_ireg_object(int shapenum, int framenum, unsigned int tilex,
00153 unsigned int tiley, unsigned int lft = 0);
00154 virtual ~Animated_ireg_object();
00155
00156 virtual void paint();
00157
00158 virtual Tile_coord get_original_tile_coord() const
00159 { return get_tile() +
00160 Tile_coord(-animator->get_deltax(),
00161 -animator->get_deltay(), 0); }
00162
00163
00164 virtual void write_ireg(DataSource* out);
00165 };
00166
00167
00168
00169
00170
00171 class Animated_ifix_object : public Ifix_game_object
00172 {
00173 Animator *animator;
00174 public:
00175 Animated_ifix_object(unsigned char *ifix);
00176 Animated_ifix_object(int shapenum, int framenum, unsigned int tilex,
00177 unsigned int tiley, unsigned int lft = 0);
00178 virtual ~Animated_ifix_object();
00179
00180 virtual void paint();
00181
00182 virtual Tile_coord get_original_tile_coord() const
00183 { return get_tile() +
00184 Tile_coord(-animator->get_deltax(),
00185 -animator->get_deltay(), 0); }
00186
00187 virtual void write_ifix(DataSource* ifix);
00188
00189 };
00190 #endif
00191
00192