Skip to content

Commit

Permalink
More code deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Aug 30, 2024
1 parent fe6acaf commit 6db5648
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/badguy/crusher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,18 +653,24 @@ Crusher::eye_position(bool right) const
break;
case RECOVERING:
{
// Amplitude dependent on size.
auto amplitude = static_cast<float>(m_sprite->get_width()) / 64.0f * 2.0f;

//Phase factor due to cooldown timer.
auto cooldown_phase_factor = (m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f;

// Phase factor due to y position.
auto y_position_phase_factor = !m_sideways ? get_pos().y / 13 : get_pos().x / 13;

auto phase_factor = y_position_phase_factor - cooldown_phase_factor;

// Eyes spin while crusher is recovering, giving a dazed impression.
return Vector(sinf((right ? 1 : -1) * // X motion of each eye is opposite of the other.
((!m_sideways ? get_pos().y / 13 : get_pos().x / 13) - // Phase factor due to y position.
(m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f)) * //Phase factor due to cooldown timer.
amplitude - (right ? 1 : -1) * // Amplitude dependent on size.
phase_factor) * amplitude - (right ? 1 : -1) *
amplitude, // Offset to keep eyes visible.

cosf((right ? 3.1415f : 0.0f) + // Eyes spin out of phase of eachother.
(!m_sideways ? get_pos().y / 13 : get_pos().x / 13) - // Phase factor due to y position.
(m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f) * //Phase factor due to cooldown timer.
amplitude - // Amplitude dependent on size.
phase_factor) * amplitude -
amplitude); // Offset to keep eyes visible.
}
default:
Expand Down

0 comments on commit 6db5648

Please sign in to comment.