void collision_check(square& another) { const float delta_x{x_pout() - another.x_pout()}; const float delta_y{y_pout() - another.y_pout()}; if ((abs(delta_y) >= abs(delta_x)) && (abs(delta_y) <= m_side)) { if (delta_y <= 0) { y_pin(another.y_pout() - m_side); reset_jumps(); } } if ((abs(delta_x) > abs(delta_y)) && (abs(delta_x) <= m_side)) { if (delta_x <= 0) { const float x_middle{another.x_pout() + 0.5f*delta_x}; x_pin(x_middle - m_radius); another.x_pin(x_middle + m_radius); } } }
void warp(square& another) { if ((sf::Keyboard::isKeyPressed(sf::Keyboard::S) && (m_winger == wing::left)) || (sf::Keyboard::isKeyPressed(sf::Keyboard::K) && (m_winger == wing::right))) { if (!warping) { const float x_pout_ = x_pout(); const float o_x_pout = another.x_pout(); if (o_x_pout > x_pout_) { if (o_x_pout <= m_windims.x - 2.5f*m_side) { m_posit.x = o_x_pout + 2.0f*m_side; } else if (o_x_pout >= 2.5f*m_side) { m_posit.x = o_x_pout - 2.0f*m_side; } } if (o_x_pout < x_pout_) { if (o_x_pout >= 2.5f*m_side) { m_posit.x = o_x_pout - 2.0f*m_side; } else if (o_x_pout <= m_windims.x - 2.5f*m_side) { m_posit.x = o_x_pout + 2.0f*m_side; } } warping = true; } } else if (warping) { warping = false; } }