1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2006 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * Declares Particles class implementing weather and spark effects
33 //global phase for the while spark structure
38 // this structure holds data for a single particle element
46 * Class holding information about particles and rendering them.
49 #define SP_TYPE_POINT 0
50 #define SP_TYPE_LINE 1
51 #define SP_TYPE_CIRCLE 2
52 #define SP_TYPE_BITMAP 3
54 #define SP_PATH_FALL 0 //free falling
55 #define SP_PATH_FOUNT 1 //going up and down
56 #define SP_PATH_FLIT 2 //flitting
57 #define SP_PATH_RAIN 3 //falling and vanishing quickly
58 #define SP_PATH_EXPL 4 //explosion (mostly used with fragments)
60 #define SP_SPAWN_NONE 0 //don't create new sparks
61 #define SP_SPAWN_FULL 1 //fill all at setup, then switch to none
62 #define SP_SPAWN_SOME 2 //add some new elements regularly
64 #define SPARK_COLOR_NONE 0
65 #define SPARK_COLOR_BLUE 1
66 #define SPARK_COLOR_GOLD 2
67 #define SPARK_COLOR_PURPLE 3
68 #define SPARK_COLOR_ICE 4
69 #define SPARK_COLOR_STONE 5
70 #define SPARK_COLOR_BLACK 6
71 #define SPARK_COLOR_CHROM 7
72 #define SPARK_COLOR_RED 8
73 #define SPARK_COLOR_GREEN 9
74 #define SPARK_COLOR_WHITE 10
75 #define SPARK_COLOR_MAGENTA 11
76 #define SPARK_COLOR_ORANGE 12
78 #define MAX_SPARK_COLOR 13
79 #define MAX_SPARK_PHASE 5
81 class GEM_EXPORT Particles
{
86 void SetBitmap(unsigned int FragAnimID
);
87 void SetPhase(ieByte ph
) { phase
= ph
; }
88 int GetPhase() const { return phase
; }
89 bool MatchPos(const Point
&p
) const { return pos
.x
==p
.x
&& pos
.y
==p
.y
; }
90 void SetType(ieByte t
, ieByte p
=SP_PATH_FALL
, ieByte st
=SP_SPAWN_NONE
)
96 void SetRegion(int x
, int y
, int w
, int h
)
103 void SetColor(ieByte c
) { color
=c
; }
104 void SetOwner(Scriptable
*o
) { owner
=o
; }
105 /* returns true if it cannot add new elements */
106 bool AddNew(const Point
&point
);
107 void Draw(const Region
&screen
);
108 void AddParticles(int count
);
109 /* returns true if it could be destroyed (didn't draw anything) */
111 int GetHeight() const { return pos
.y
+pos
.h
; }
114 ieDword target
; //could be 0, in that case target is pos
115 ieWord size
; //spark number
116 ieWord last_insert
;//last spark idx added
117 Scriptable
*owner
; //could be area or game or actor
119 ieByte phase
; //global phase
120 ieByte type
; //draw type (snow, rain)
121 ieByte path
; //path type
122 ieByte color
; //general spark color
124 //use char animations for the fragment animations
125 //1. the cycles are loaded only when needed
126 //2. the fragments ARE avatar animations in the original IE (for some unknown reason)
127 CharAnimations
*fragments
;
130 #endif // ! PARTICLES_H