53
53
m_type = TYPE_SPIKA;
56
color_type = COL_DEFAULT;
57
m_detection_size = 0.0f;
60
m_color_type = COL_DEFAULT;
60
61
Set_Color( COL_ORANGE );
63
64
cSpika *cSpika :: Copy( void )
65
66
cSpika *spika = new cSpika( m_start_pos_x, m_start_pos_y );
66
spika->Set_Color( color_type );
67
spika->Set_Color( m_color_type );
74
75
Set_Pos( static_cast<float>(attributes.getValueAsInteger( "posx" )), static_cast<float>(attributes.getValueAsInteger( "posy" )), 1 );
76
Set_Color( static_cast<DefaultColor>(Get_Color_Id( attributes.getValueAsString( "color", Get_Color_Name( color_type ) ).c_str() )) );
77
Set_Color( static_cast<DefaultColor>(Get_Color_Id( attributes.getValueAsString( "color", Get_Color_Name( m_color_type ) ).c_str() )) );
79
80
void cSpika :: Save_To_Stream( ofstream &file )
87
88
file << "\t\t<Property name=\"posx\" value=\"" << static_cast<int>(m_start_pos_x) << "\" />" << std::endl;
88
89
file << "\t\t<Property name=\"posy\" value=\"" << static_cast<int>(m_start_pos_y) << "\" />" << std::endl;
90
file << "\t\t<Property name=\"color\" value=\"" << Get_Color_Name( color_type ) << "\" />" << std::endl;
91
file << "\t\t<Property name=\"color\" value=\"" << Get_Color_Name( m_color_type ) << "\" />" << std::endl;
93
94
file << "\t</enemy>" << std::endl;
104
105
// clear old images
109
if( color_type == COL_ORANGE )
111
m_images.push_back( pVideo->Get_Surface( "enemy/spika/orange.png" ) );
114
detection_size = 160;
119
else if( color_type == COL_GREEN )
121
m_images.push_back( pVideo->Get_Surface( "enemy/spika/green.png" ) );
124
detection_size = 220;
129
else if( color_type == COL_GREY )
131
m_images.push_back( pVideo->Get_Surface( "enemy/spika/grey.png" ) );
134
detection_size = 330;
110
if( m_color_type == COL_ORANGE )
112
Add_Image( pVideo->Get_Surface( "enemy/spika/orange.png" ) );
115
m_detection_size = 160.0f;
118
m_fire_resistant = 0;
119
m_ice_resistance = 0.0f;
121
else if( m_color_type == COL_GREEN )
123
Add_Image( pVideo->Get_Surface( "enemy/spika/green.png" ) );
126
m_detection_size = 220.0f;
129
m_fire_resistant = 0;
130
m_ice_resistance = 0.1f;
132
else if( m_color_type == COL_GREY )
134
Add_Image( pVideo->Get_Surface( "enemy/spika/grey.png" ) );
137
m_detection_size = 330.0f;
140
m_fire_resistant = 1;
141
m_ice_resistance = 0.5f;
141
printf( "Error : Unknown Spika Color %d\n", color_type );
145
printf( "Error : Unknown Spika Color %d\n", m_color_type );
144
148
Set_Image_Num( 0, 1 );
146
150
m_name = "Spika ";
147
m_name += _(Get_Color_Name( color_type ).c_str());
151
m_name += _(Get_Color_Name( m_color_type ).c_str());
150
154
void cSpika :: DownGrade( bool force /* = 0 */ )
153
157
m_massive_type = MASS_PASSIVE;
157
161
Set_Scale_Directions( 1, 1, 1, 1 );
159
163
// default stomp death
167
Set_Rotation_Z( 180 );
171
Set_Rotation_Z( 180.0f );
171
void cSpika :: DieStep( void )
175
void cSpika :: Update_Dying( void )
173
counter += pFramerate->speedfactor * 0.1f;
177
m_counter += pFramerate->m_speed_factor * 0.1f;
177
181
// a little bit upwards first
182
if( m_counter < 0.3f )
182
186
// if not below the screen fall
183
187
else if( m_pos_y < game_res_h + m_col_rect.m_h )
187
Add_Scale( -pFramerate->speedfactor * 0.01f );
191
Add_Scale( -pFramerate->m_speed_factor * 0.01f );
189
193
// if below disable
223
227
GL_rect rect_right = rect_left;
225
rect_left.m_x -= detection_size + ( m_col_rect.m_w / 2 );
226
rect_left.m_w += detection_size;
229
rect_left.m_x -= m_detection_size + ( m_col_rect.m_w / 2 );
230
rect_left.m_w += m_detection_size;
228
232
rect_right.m_x -= m_col_rect.m_w / 2;
229
rect_right.m_w += detection_size;
233
rect_right.m_w += m_detection_size;
232
236
// if player is left
233
237
if( pPlayer->maryo_type != MARYO_GHOST && player_rect.Intersects( rect_left ) )
235
if( m_velx > -speed )
239
if( m_velx > -m_speed )
237
m_velx -= speed * 0.1f * pFramerate->speedfactor;
241
m_velx -= m_speed * 0.1f * pFramerate->m_speed_factor;
239
if( m_velx < -speed )
243
if( m_velx < -m_speed )
245
249
// if player is right
246
250
else if( pPlayer->maryo_type != MARYO_GHOST && player_rect.Intersects( rect_right ) )
252
if( m_velx < m_speed )
250
m_velx += speed * 0.1f * pFramerate->speedfactor;
254
m_velx += m_speed * 0.1f * pFramerate->m_speed_factor;
256
if( m_velx > m_speed )
262
m_velx -= (m_velx * 0.03f) * pFramerate->speedfactor;
266
m_velx -= (m_velx * 0.03f) * pFramerate->m_speed_factor;
265
269
// play walking sound based on speed
266
if( walk_count < m_rot_z - 30 || walk_count > m_rot_z + 30 )
270
if( m_walk_count < m_rot_z - 30.0f || m_walk_count > m_rot_z + 30.0f )
268
272
pAudio->Play_Sound( "enemy/spika/move.ogg" );
270
walk_count = m_rot_z;
274
m_walk_count = m_rot_z;
290
294
Col_Valid_Type basic_valid = Validate_Collision_Ghost( obj );
292
296
// found valid collision
293
if( basic_valid != COL_VTYPE_NO_GHOST )
297
if( basic_valid != COL_VTYPE_NOT_POSSIBLE )
295
299
return basic_valid;
298
302
if( obj->m_massive_type == MASS_MASSIVE )
300
if( obj->m_type == TYPE_ROKKO )
302
return COL_VTYPE_NOT_VALID;
304
if( obj->m_type == TYPE_GEE )
306
return COL_VTYPE_NOT_VALID;
308
if( obj->m_type == TYPE_TURTLE_BOSS )
310
return COL_VTYPE_NOT_VALID;
312
if( obj->m_type == TYPE_FURBALL_BOSS )
314
return COL_VTYPE_NOT_VALID;
316
if( obj->m_type == TYPE_STATIC_ENEMY )
318
return COL_VTYPE_NOT_VALID;
304
switch( obj->m_type )
308
return COL_VTYPE_NOT_VALID;
312
return COL_VTYPE_NOT_VALID;
314
case TYPE_TURTLE_BOSS:
316
return COL_VTYPE_NOT_VALID;
318
case TYPE_FURBALL_BOSS:
320
return COL_VTYPE_NOT_VALID;
322
case TYPE_STATIC_ENEMY:
324
return COL_VTYPE_NOT_VALID;
321
332
if( obj->m_sprite_array == ARRAY_ENEMY )
334
// collide only if moving
335
if( !Is_Float_Equal( m_velx, 0.0f ) )
326
337
// if enemy is spika and more powerful
327
if( obj->m_type == TYPE_SPIKA && speed < static_cast<cSpika *>(obj)->speed )
338
if( obj->m_type == TYPE_SPIKA && m_speed < static_cast<cSpika *>(obj)->m_speed )
329
340
return COL_VTYPE_BLOCKING;
338
349
return COL_VTYPE_BLOCKING;
340
if( obj->m_massive_type == MASS_HALFMASSIVE )
351
else if( obj->m_massive_type == MASS_HALFMASSIVE )
342
353
// if moving downwards and the object is on bottom
343
354
if( m_vely >= 0 && Is_On_Top( obj ) )
376
381
cEnemy *enemy = static_cast<cEnemy *>(pActive_Sprite_Manager->Get_Pointer( collision->number ));
385
390
if( enemy->m_type == TYPE_SPIKA )
387
392
cSpika *spika = static_cast<cSpika *>(enemy);
389
394
// if colliding spika is more powerful
390
if( speed < spika->speed )
395
if( m_speed < spika->m_speed )
392
397
//enemy->Send_Collision( collision );
401
406
cTurtleBoss *turtle_boss = static_cast<cTurtleBoss *>(enemy);
403
408
// downgrade until state change
404
for( int i = turtle_boss->hits; i < turtle_boss->max_hits; i++ )
409
for( int i = turtle_boss->m_hits; i < turtle_boss->m_max_hits; i++ )
406
411
turtle_boss->DownGrade();
409
// turtle kills spika
412
417
// state change for furball boss
413
418
else if( enemy->m_type == TYPE_FURBALL_BOSS )
415
420
enemy->DownGrade();
424
// enemies that also hit us
425
else if( ( enemy->m_type == TYPE_TURTLE && enemy->m_state == STA_RUN ) )
427
enemy->DownGrade( 1 );
431
// enemies that only hit us
432
else if( enemy->m_type == TYPE_SPIKEBALL )
422
pAudio->Play_Sound( enemy->kill_sound );
423
pHud_Points->Add_Points( enemy->kill_points, m_pos_x + m_image->m_w / 3, m_pos_y - 5, "", static_cast<Uint8>(255), 1 );
441
if( Is_Float_Equal( m_velx, 0.0f ) )
446
pAudio->Play_Sound( enemy->m_kill_sound );
447
pHud_Points->Add_Points( enemy->m_kill_points, m_pos_x + m_image->m_w / 3, m_pos_y - 5, "", static_cast<Uint8>(255), 1 );
424
448
enemy->DownGrade( 1 );