00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef EFFECTS_H
00022 #define EFFECTS_H 1
00023
00024 #include <string>
00025
00026 #include "tqueue.h"
00027 #include "tiles.h"
00028 #include "singles.h"
00029
00030 class Xform_palette;
00031 class PathFinder;
00032 class Game_object;
00033 class Game_window;
00034 class Image_window8;
00035 class Shape_frame;
00036 class Actor;
00037 class Special_effect;
00038 class Text_effect;
00039
00040
00041
00042
00043 class Effects_manager
00044 {
00045 Game_window *gwin;
00046 Special_effect *effects;
00047 Text_effect *texts;
00048 public:
00049 Effects_manager(Game_window *g) : gwin(g), effects(0), texts(0)
00050 { }
00051 ~Effects_manager();
00052
00053 void add_text(const char *msg, Game_object *item);
00054 void add_text(const char *msg, int x, int y);
00055 void center_text(const char *msg);
00056 void add_effect(Special_effect *effect);
00057 void add_text_effect(Text_effect *txt);
00058 void remove_text_effect(Game_object *item);
00059
00060 void remove_effect(Special_effect *effect);
00061 void remove_text_effect(Text_effect *txt);
00062 void remove_all_effects(bool repaint=false);
00063 void remove_text_effects();
00064
00065 void remove_weather_effects(int dist = 0);
00066 int get_weather();
00067 void paint();
00068 void paint_text();
00069 };
00070
00071
00072
00073
00074 class Special_effect : public Time_sensitive, public Game_singletons
00075 {
00076 Special_effect *next, *prev;
00077 public:
00078 friend class Effects_manager;
00079 Special_effect() : next(0), prev(0)
00080 { }
00081 virtual ~Special_effect()
00082 { }
00083
00084 virtual void paint();
00085 virtual int is_weather()
00086 { return 0; }
00087 };
00088
00089
00090
00091
00092 class Sprites_effect : public Special_effect
00093 {
00094 protected:
00095 ShapeID sprite;
00096
00097
00098 int frames;
00099 Game_object *item;
00100 Tile_coord pos;
00101 int xoff, yoff;
00102 int deltax, deltay;
00103 void add_dirty(int frnum);
00104 public:
00105 Sprites_effect(int num, Tile_coord p, int dx = 0, int dy = 0,
00106 int delay = 0);
00107 Sprites_effect(int num, Game_object *it,
00108 int xf, int yf, int dx, int dy);
00109
00110 virtual void handle_event(unsigned long time, long udata);
00111
00112 virtual void paint();
00113 };
00114
00115
00116
00117
00118 class Explosion_effect : public Sprites_effect
00119 {
00120 Game_object *explode;
00121 int weapon;
00122 public:
00123 Explosion_effect(Tile_coord p, Game_object *exp, int delay = 0,
00124 int weap = -1);
00125 virtual void handle_event(unsigned long time, long udata);
00126 };
00127
00128
00129
00130
00131
00132 class Projectile_effect : public Special_effect
00133 {
00134 Actor *attacker;
00135 Game_object *target;
00136 int projectile_shape;
00137 ShapeID sprite;
00138 int weapon;
00139 int frames;
00140 PathFinder *path;
00141 Tile_coord pos;
00142 bool return_path;
00143 bool no_blocking;
00144
00145 void add_dirty();
00146 void init(Tile_coord s, Tile_coord t);
00147 public:
00148 Projectile_effect(Actor *att, Game_object *to, int shnum,
00149 int weap = 0);
00150
00151 Projectile_effect(Tile_coord s, Tile_coord d, int shnum, int weap);
00152 Projectile_effect(Tile_coord s, Game_object *to, int shnum, int weap,
00153 bool retpath = false);
00154 ~Projectile_effect();
00155
00156 virtual void handle_event(unsigned long time, long udata);
00157
00158 virtual void paint();
00159 };
00160
00161
00162
00163
00164
00165 class Death_vortex : public Special_effect
00166 {
00167 ShapeID vortex;
00168 Actor *target;
00169 Tile_coord pos;
00170 int frames;
00171 uint32 stop_time;
00172 uint32 next_damage_time;
00173 int add_dirty();
00174 public:
00175 Death_vortex(Game_object *trg, Tile_coord tp);
00176
00177 virtual void handle_event(unsigned long time, long udata);
00178
00179 virtual void paint();
00180 };
00181
00182
00183
00184
00185
00186
00187 class Text_effect : public Time_sensitive, public Game_singletons
00188 {
00189 Text_effect *next, *prev;
00190 std::string msg;
00191 Game_object *item;
00192 Tile_coord pos;
00193 short width, height;
00194 int num_ticks;
00195 void add_dirty();
00196 void init();
00197 public:
00198 friend class Effects_manager;
00199 Text_effect(const std::string &m, Game_object *it);
00200 Text_effect(const std::string &m, int t_x, int t_y);
00201
00202 virtual void handle_event(unsigned long curtime, long udata);
00203
00204 virtual void paint();
00205
00206 int is_text(Game_object *it)
00207 { return it == item; }
00208 };
00209
00210
00211
00212
00213 class Weather_effect : public Special_effect
00214 {
00215 protected:
00216 uint32 stop_time;
00217 int num;
00218 Tile_coord eggloc;
00219 public:
00220 Weather_effect(int duration, int delay, int n, Game_object *egg = 0);
00221 virtual ~Weather_effect()
00222 { }
00223
00224 int out_of_range(Tile_coord& avpos, int dist);
00225 virtual int is_weather()
00226 { return 1; }
00227 int get_num() { return num; }
00228 };
00229
00230
00231
00232
00233 class Raindrop
00234 {
00235 unsigned char oldpix;
00236 unsigned char yperx;
00237 long ax, ay;
00238 public:
00239 Raindrop() : oldpix(0xff), yperx(1), ax(-1), ay(-1)
00240 { }
00241 void paint(Image_window8 *iwin, int scrolltx, int scrollty,
00242 Xform_palette& xform);
00243
00244 void next(Image_window8 *iwin, int scrolltx, int scrollty,
00245 Xform_palette& xform, int w, int h);
00246 void next_random(Image_window8 *iwin, int scrolltx, int scrollty,
00247 Xform_palette& xform, int w, int h);
00248 };
00249
00250
00251
00252
00253 class Rain_effect : public Weather_effect
00254 {
00255 protected:
00256 #define MAXDROPS 200
00257 Raindrop drops[MAXDROPS];
00258 int num_drops;
00259 public:
00260 Rain_effect(int duration, int delay = 0,
00261 int ndrops = MAXDROPS, int n = -1, Game_object *egg = 0)
00262 : Weather_effect(duration, delay, n, egg),
00263 num_drops(ndrops)
00264 { }
00265
00266 virtual void handle_event(unsigned long curtime, long udata);
00267
00268 virtual void paint();
00269 };
00270
00271
00272
00273
00274 class Lightning_effect : public Weather_effect
00275 {
00276 static int active;
00277 bool flashing;
00278 friend class Storm_effect;
00279 public:
00280 Lightning_effect(int duration, int delay = 0)
00281 : Weather_effect(duration, delay, -1), flashing(false)
00282 { }
00283 ~Lightning_effect();
00284
00285 virtual void handle_event(unsigned long curtime, long udata);
00286 };
00287
00288
00289
00290
00291 class Storm_effect : public Weather_effect
00292 {
00293 int start;
00294 public:
00295 Storm_effect(int duration, int delay = 0, Game_object *egg = 0);
00296
00297 virtual void handle_event(unsigned long curtime, long udata);
00298 virtual ~Storm_effect();
00299 };
00300
00301
00302
00303
00304 class Sparkle_effect : public Rain_effect
00305 {
00306 public:
00307 Sparkle_effect(int duration, int delay = 0, Game_object *egg = 0)
00308
00309 : Rain_effect(duration, delay, 50, 3, egg)
00310 { }
00311
00312 virtual void handle_event(unsigned long curtime, long udata);
00313 };
00314
00315
00316
00317
00318 class Cloud
00319 {
00320 ShapeID cloud;
00321 long wx, wy;
00322 short deltax, deltay;
00323 int count;
00324 int max_count;
00325 uint32 start_time;
00326 static int randcnt;
00327 void set_start_pos(Shape_frame *shape, int w, int h, int& x, int& y);
00328 public:
00329 Cloud(short dx, short dy);
00330
00331 void next(Game_window *gwin, unsigned long curtime, int w, int h);
00332 void paint();
00333 };
00334
00335
00336
00337
00338 class Clouds_effect : public Weather_effect
00339 {
00340 int num_clouds;
00341 Cloud **clouds;
00342 public:
00343 Clouds_effect(int duration, int delay = 0, Game_object *egg = 0);
00344
00345 virtual void handle_event(unsigned long curtime, long udata);
00346
00347 virtual void paint();
00348 virtual ~Clouds_effect()
00349 { delete [] clouds; }
00350 };
00351
00352
00353
00354
00355 class Earthquake : public Time_sensitive
00356 {
00357 int len;
00358 int i;
00359 public:
00360 Earthquake(int l) : len(l), i(0)
00361 {
00362 }
00363
00364 virtual void handle_event(unsigned long curtime, long udata);
00365 };
00366
00367
00368
00369
00370 class Fire_field_effect : public Special_effect
00371 {
00372 Game_object *field;
00373 public:
00374 Fire_field_effect(Tile_coord t);
00375 virtual void handle_event(unsigned long curtime, long udata);
00376 };
00377
00378 #endif
00379