void cRokko :: Handle_Collision_Player( cObjectCollision *collision ) { // if invalid if( collision->direction == DIR_UNDEFINED ) { return; } if( m_direction == DIR_LEFT || m_direction == DIR_RIGHT ) { // if invincible if( pPlayer->invincible > 0.0f ) { return; } if( collision->direction == DIR_TOP && pPlayer->m_state != STA_FLY && pPlayer->maryo_type == MARYO_BOOTS && pPlayer->weapon3_amount > 0 ) { pPlayer->Check_Weapon3(); pHud_Points->Add_Points( m_kill_points, pPlayer->m_pos_x + pPlayer->m_image->m_w / 3, pPlayer->m_pos_y - 5, "", static_cast<Uint8>(255), 1 ); pAudio->Play_Sound( m_kill_sound ); pPlayer->Action_Jump( 1 ); pPlayer->Add_Kill_Multiplier(); DownGrade(); } else { pPlayer->DownGrade_Player(); } } else if( m_direction == DIR_UP || m_direction == DIR_DOWN ) { if( ( collision->direction == DIR_LEFT || collision->direction == DIR_LEFT ) && pPlayer->m_state == STA_FLY ) { pHud_Points->Add_Points( m_kill_points, pPlayer->m_pos_x + pPlayer->m_image->m_w / 3, pPlayer->m_pos_y - 5, "", static_cast<Uint8>(255), 1 ); pAudio->Play_Sound( m_kill_sound ); pPlayer->Add_Kill_Multiplier(); DownGrade(); } else { pPlayer->DownGrade_Player(); } } }
void cRokko::Handle_Collision_Player(cObjectCollision* collision) { // if invalid if (collision->m_direction == DIR_UNDEFINED) { return; } if (m_direction == DIR_LEFT || m_direction == DIR_RIGHT) { // if invincible if (pLevel_Player->m_invincible > 0.0f) { return; } if (collision->m_direction == DIR_TOP && pLevel_Player->m_state != STA_FLY) { pHud_Points->Add_Points(m_kill_points, m_pos_x + m_rect.m_w / 3, m_pos_y - 10.0f, "", static_cast<Uint8>(255), 1); pAudio->Play_Sound(m_kill_sound); pLevel_Player->Action_Jump(1); pLevel_Player->Add_Kill_Multiplier(); DownGrade(); } else { pLevel_Player->DownGrade_Player(); } } else if (m_direction == DIR_UP || m_direction == DIR_DOWN) { if ((collision->m_direction == DIR_LEFT || collision->m_direction == DIR_LEFT) && pLevel_Player->m_state == STA_FLY) { pHud_Points->Add_Points(m_kill_points, m_pos_x, m_pos_y - 5.0f, "", static_cast<Uint8>(255), 1); pAudio->Play_Sound(m_kill_sound); pLevel_Player->Add_Kill_Multiplier(); DownGrade(); } else { pLevel_Player->DownGrade_Player(); } } }
void cEnemy::Update_Gravity(void) { if (!m_ground_object) { if (m_vely < 25) { Add_Velocity(0, 1.5f); } if (m_col_rect.m_y > pActive_Camera->limit_rect.m_y + game_res_h) { DownGrade(1); } } else { if (m_vely > 0) { m_vely = 0; } } }
void cMovingSprite :: Move_With_Ground( void ) { if( !m_ground_object || ( m_ground_object->m_sprite_array != ARRAY_ACTIVE && m_ground_object->m_sprite_array != ARRAY_ENEMY ) ) // || m_ground_object->sprite_array == ARRAY_MASSIVE { return; } cMovingSprite *moving_ground_object = dynamic_cast<cMovingSprite *>(m_ground_object); // invalid moving sprite if( !moving_ground_object ) { return; } // does not move if( Is_Float_Equal( moving_ground_object->m_velx, 0.0f ) && Is_Float_Equal( moving_ground_object->m_vely, 0.0f ) ) { return; } // check ground first because of the moving object velocity Check_on_Ground(); // save posx for possible can not move test float posy_orig = m_pos_y; /* stop object from getting stopped of the moving object which did not yet move itself * for example the player always moves as last */ bool is_massive = 0; if( moving_ground_object->m_massive_type == MASS_MASSIVE ) { moving_ground_object->m_massive_type = MASS_PASSIVE; is_massive = 1; } // move Col_Move( moving_ground_object->m_velx, moving_ground_object->m_vely, 0, 0, 0 ); if( is_massive ) { moving_ground_object->m_massive_type = MASS_MASSIVE; } // if ground object is moving up if( moving_ground_object->m_vely < -0.01f ) { // test if we could not move upwards because something did block us in Col_Move() if( Is_Float_Equal( m_pos_y, posy_orig ) ) { // massive if( moving_ground_object->m_massive_type == MASS_MASSIVE ) { // got crunched DownGrade( 1 ); } // halfmassive else if( moving_ground_object->m_massive_type == MASS_HALFMASSIVE ) { // lost ground Move( 0.0f, 1.9f, 1 ); Reset_On_Ground(); } } } }