00001
00002
00003
00004
00005
00006
00007
00008 #ifndef QAF_OBJ_SPRITEPARTICLEOBJ_H
00009 #define QAF_OBJ_SPRITEPARTICLEOBJ_H
00010
00011 #include "../qafGameObj.h"
00012 #include <hgesprite.h>
00013
00014 namespace qaf {
00015
00029 class SpriteParticleObj : public GameObj {
00030 public:
00031
00051 SpriteParticleObj (
00052 const hgeSprite * sprite,
00053 float x, float y,
00054 float angle,
00055 float vx, float vy,
00056 float vr,
00057 float ax, float ay,
00058 float initialSizeX, float initialSizeY,
00059 float finalSizeX, float finalSizeY,
00060 DWORD initialColor, DWORD finalColor,
00061 DWORD blendMode,
00062 float lifetime );
00063
00064
00065
00069 inline hgeSprite * getSprite () {
00070 return &sprite;
00071 }
00072
00076 inline bool isDead () {
00077 return (timer >= lifetime);
00078 }
00079
00084 void getPos ( float * _x, float * _y, float * _angle ) {
00085 if ( _x )
00086 *_x = x;
00087 if ( _y )
00088 *_y = y;
00089 if ( _angle )
00090 *_angle = angle;
00091 }
00092
00097 inline void getVel ( float * _vx, float * _vy, float * _vr ) {
00098 if ( _vx )
00099 *_vx = vx;
00100 if ( _vy )
00101 *_vy = vy;
00102 if ( _vr )
00103 *_vr = vr;
00104 }
00105
00109 inline DWORD getColor () {
00110 float timeRatio = (timer/lifetime);
00111
00112 int newR = initialR + (int) (timeRatio * deltaR);
00113 int newG = initialG + (int) (timeRatio * deltaG);
00114 int newB = initialB + (int) (timeRatio * deltaB);
00115 int newA = initialA + (int) (timeRatio * deltaA);
00116
00117 return ARGB( newA, newR, newG, newB );
00118 }
00119
00123 inline DWORD getBlendMode () {
00124 return blendMode;
00125 }
00126
00130 inline void getSize ( float * xScale, float * yScale ) {
00131 float timeRatio = (timer/lifetime);
00132
00133 if ( xScale )
00134 *xScale = initialSizeX + (timeRatio * (finalSizeX - initialSizeX));
00135 if ( yScale )
00136 *yScale = initialSizeY + (timeRatio * (finalSizeY - initialSizeY));
00137 }
00138
00142 inline float getAge () {
00143 return timer;
00144 }
00145
00146
00147
00148 void update ( int objLayer, float dt );
00149 void render ( int objLayer, float scrollX, float scrollY );
00150
00151 protected:
00152 hgeSprite sprite;
00153 float x, y, angle, vx, vy, vr, ax, ay, initialSizeX, initialSizeY, finalSizeX, finalSizeY, lifetime;
00154 int initialR, initialG, initialB, initialA;
00155 int deltaR, deltaG, deltaB, deltaA;
00156 DWORD blendMode;
00157 float timer;
00158 };
00159
00160 }
00161
00162
00163
00164 #endif
00165