43
void cGlobal_effect :: Init_default( void )
48
void cGlobal_effect :: Init( void )
43
void cGlobal_effect :: Init_Anim( void )
50
45
if( ge_type == GL_EFF_NONE )
55
if( ge_type == GL_EFF_FALLING || ge_type == GL_EFF_FLYING )
50
if( ge_type == GL_EFF_FALLING )
57
// if the image doesn't exists
52
// image doesn't exist
58
53
if( !pVideo->Get_Surface( image_filename ) )
62
// image exists valid effect
65
60
image = pVideo->Get_Surface( image_filename );
86
81
void cGlobal_effect :: Clear( void )
88
cParticleAnimation::Clear();
83
cParticle_Emitter::Clear();
90
85
ge_type = GL_EFF_NONE;
92
87
image_filename.clear();
94
Set_Emitter_Rect( GL_rect( 0, 0, GAME_RES_W, 0 ) );
89
Set_Emitter_Rect( 0, 0, static_cast<float>(game_res_w), 0 );
95
90
Set_Emitter_Time_to_Live( -1 );
96
Set_Emitter_Iteration_Interval( 1 * 0.3f );
91
Set_Emitter_Iteration_Interval( 0.3f );
92
Set_Pos_Z( 0.12f, 0 );
98
93
Set_Time_to_Live( 7, 0 );
99
94
Set_Scale( 0.2f, 0.2f );
100
95
Set_Speed( 2, 8 );
101
Set_DirectionRange( 0, 90 );
102
Set_ConstRotationZ( 0.5f, 10 );
96
Set_Direction_Range( 0, 90 );
97
Set_Rotation( 0, 0, 0, 1 );
98
Set_Const_Rotation_Z( -5, 10 );
107
void cGlobal_effect :: Create_from_Stream( XMLAttributes &attributes )
103
void cGlobal_effect :: Create_from_Stream( CEGUI::XMLAttributes &attributes )
110
Set_type( (GlobalEffectType)attributes.getValueAsInteger( "type", GL_EFF_NONE ) );
106
Set_Type( (GlobalEffectType)attributes.getValueAsInteger( "type", ge_type ) );
112
Set_image( attributes.getValueAsString( "image" ).c_str() );
108
Set_Image( attributes.getValueAsString( "image", image_filename ).c_str() );
114
Set_Emitter_Rect( static_cast<float>(attributes.getValueAsInteger( "rect_x", 0 )), static_cast<float>(attributes.getValueAsInteger( "rect_y", 0 )), static_cast<float>(attributes.getValueAsInteger( "rect_w", GAME_RES_W )), static_cast<float>(attributes.getValueAsInteger( "rect_h", 0 )) );
115
// if start position is 0 change it
116
if( startposx == 0 && startposy == 0 )
118
Set_Emitter_Rect( startposx, -1, rect.w, rect.h );
110
Set_Emitter_Rect( static_cast<float>(attributes.getValueAsInteger( "rect_x", static_cast<int>(startposx) )), static_cast<float>(attributes.getValueAsInteger( "rect_y", static_cast<int>(startposy) )), static_cast<float>(attributes.getValueAsInteger( "rect_w", static_cast<int>(rect.w) )), static_cast<float>(attributes.getValueAsInteger( "rect_h", static_cast<int>(rect.h) )) );
121
Set_ZPos( attributes.getValueAsFloat( "z", 0.12f ), attributes.getValueAsFloat( "z_rand" ) );
112
Set_Pos_Z( attributes.getValueAsFloat( "z", posz ), attributes.getValueAsFloat( "z_rand", posz_rand ) );
123
114
if( attributes.exists( "time_to_live" ) )
125
Set_Time_to_Live( attributes.getValueAsFloat( "time_to_live", 7 ) );
116
Set_Time_to_Live( attributes.getValueAsFloat( "time_to_live", time_to_live ), attributes.getValueAsFloat( "time_to_live_rand", time_to_live_rand ) );
127
118
// if not set uses old Lifetime mod
140
131
Set_Emitter_Iteration_Interval( ( 1 / attributes.getValueAsFloat( "creation_speed", 0.3f ) ) * 0.032f );
143
Set_Scale( attributes.getValueAsFloat( "scale", 0.2f ), attributes.getValueAsFloat( "scale_rand", 0.2f ) );
134
Set_Scale( attributes.getValueAsFloat( "scale", size_scale ), attributes.getValueAsFloat( "scale_rand", size_scale_rand ) );
145
Set_Speed( attributes.getValueAsFloat( "speed", 2 ), attributes.getValueAsFloat( "speed_rand", 8 ) );
136
Set_Speed( attributes.getValueAsFloat( "speed", vel ), attributes.getValueAsFloat( "speed_rand", vel_rand ) );
147
Set_DirectionRange( attributes.getValueAsFloat( "dir_range_start", 0 ), attributes.getValueAsFloat( "dir_range_size", 90 ) );
138
Set_Direction_Range( attributes.getValueAsFloat( "dir_range_start", angle_start ), attributes.getValueAsFloat( "dir_range_size", angle_range ) );
140
Set_Rotation( attributes.getValueAsFloat( "rot_x", start_rotx ), attributes.getValueAsFloat( "rot_y", start_roty ), attributes.getValueAsFloat( "rot_z", start_rotz ), 1 );
148
141
// Constant Rotation Z
149
Set_ConstRotationZ( attributes.getValueAsFloat( "const_rotz", 0.5f ), attributes.getValueAsFloat( "const_rotz_rand", 10 ) );
142
Set_Const_Rotation_Z( attributes.getValueAsFloat( "const_rotz", const_rotz ), attributes.getValueAsFloat( "const_rotz_rand", const_rotz_rand ) );
152
145
void cGlobal_effect :: Save_to_Stream( ofstream &file )
215
Set_Pos( pCamera->x, pCamera->y );
213
Set_Pos( startposx + pActive_Camera->x, startposy + pActive_Camera->y );
216
// update particle animation
217
cParticle_Emitter::Update();
219
void cGlobal_effect :: Update_anim( void )
220
void cGlobal_effect :: Update_Particles( void )
221
// find out of camera objects and move them to the opposite direction
223
GL_rect camera_rect = GL_rect( pCamera->x, pCamera->y, GAME_RES_W, GAME_RES_H );
222
GL_rect camera_rect = GL_rect( pActive_Camera->x, pActive_Camera->y, static_cast<float>(game_res_w), static_cast<float>(game_res_h) );
225
224
for( ParticleList::iterator itr = objects.begin(), itr_end = objects.end(); itr != itr_end; ++itr )
227
// get animation particle pointer
226
// get animation particle pointer
228
227
cParticle *obj = static_cast<cParticle *>(*itr);
230
229
GL_rect anim_rect = GL_rect( obj->posx, obj->posy, obj->rect.w, obj->rect.h );
232
231
// if not on screen
233
if( !Col_Box( &anim_rect, &camera_rect ) )
232
if( !Col_Box( &camera_rect, &anim_rect ) )
236
if( obj->posx + image->w < pCamera->x )
235
if( anim_rect.x + anim_rect.w < camera_rect.x )
239
obj->Set_PosX( pCamera->x + camera_rect.w );
238
obj->Set_Pos_X( camera_rect.x + camera_rect.w - 1 );
242
else if( obj->posx > pCamera->x + camera_rect.w )
241
else if( anim_rect.x > camera_rect.x + camera_rect.w )
245
obj->Set_PosX( pCamera->x - image->w );
244
obj->Set_Pos_X( camera_rect.x + 1 );
248
else if( obj->posy < pCamera->y - image->h - 1 )
247
else if( anim_rect.y + anim_rect.h < camera_rect.y )
250
obj->Set_PosY( pCamera->y + camera_rect.h );
250
obj->Set_Pos_Y( camera_rect.y + camera_rect.h - 1 );
253
else if( obj->posy > pCamera->y + camera_rect.h + 1 )
253
else if( anim_rect.y > camera_rect.y + camera_rect.h )
255
obj->Set_PosY( pCamera->y - image->h );
256
obj->Set_Pos_Y( camera_rect.y + 1 );
260
// update particle animation
261
cParticleAnimation::Update();
264
262
void cGlobal_effect :: Draw( void )
266
cParticleAnimation::Draw();
264
cParticle_Emitter::Draw();
269
void cGlobal_effect :: Set_type( GlobalEffectType ntype )
267
void cGlobal_effect :: Set_Type( GlobalEffectType ntype )
274
void cGlobal_effect :: Set_type( string ntype )
272
void cGlobal_effect :: Set_Type( string ntype )
276
274
if( ntype.compare( "Disabled" ) == 0 )
278
276
ge_type = GL_EFF_NONE;
280
else if( ntype.compare( "Falling" ) == 0 )
278
else if( ntype.compare( "Falling" ) == 0 || ntype.compare( "Default" ) == 0 )
282
280
ge_type = GL_EFF_FALLING;
284
else if( ntype.compare( "Flying" ) == 0 )
286
ge_type = GL_EFF_FLYING;
290
284
printf( "Warning : Unknown Global Effect type %s\n", ntype.c_str() );
294
void cGlobal_effect :: Set_image( string nimg_file )
288
void cGlobal_effect :: Set_Image( string nimg_file )
296
290
image_filename = nimg_file;
299
string cGlobal_effect :: Get_Typename( void )
293
string cGlobal_effect :: Get_Type_Name( void )
301
295
if( ge_type == GL_EFF_NONE )