-
-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various crusher fixes #3047
base: master
Are you sure you want to change the base?
Various crusher fixes #3047
Conversation
Will test tm. |
I've added a fix for an issue found by frost, where roots would spawn in the wrong direction. |
@bruhmoent Could you test as well? |
Yes. I will soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested
I moved some code out but I don't know what |
@Vankata453 @MatusGuy Can you guys test the code changes and merge maybe? |
if ((hit.left || hit.right)) { | ||
if (m_ignore_sideways_crush) { | ||
m_ignore_sideways_crush = false; | ||
} | ||
else { | ||
kill(true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tux isn't killed immediately when crushed vertically, then why can't it also happen here? This way you remove the ignore_sidways_crush thing. But I might be missing something
{ | ||
// 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. | ||
static_cast<float>(m_sprite->get_width()) / 64.0f * 2.0f - (right ? 1 : -1) * // Amplitude dependent on size. | ||
static_cast<float>(m_sprite->get_width()) / 64.0f * 2.0f, // Offset to keep eyes visible. | ||
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. | ||
static_cast<float>(m_sprite->get_width()) / 64.0f * 2.0f - // Amplitude dependent on size. | ||
static_cast<float>(m_sprite->get_width()) / 64.0f * 2.0f); // Offset to keep eyes visible. | ||
phase_factor) * amplitude - | ||
amplitude); // Offset to keep eyes visible. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Halelujah thanks for fixing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the sideways crushing behaviour, sometimes gets Tux stuck in the wall when crushed, but he's invincible so it should be fine. I'm just not sure if that might open the door for some glitchy skips in levels.
// If the other object is the player, and the collision is at the | ||
// bottom of the crusher, hurt the player. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't reflect the changes (sideways collision also now hurts the player).
if ((hit.left || hit.right)) { | ||
if (m_ignore_sideways_crush) { | ||
m_ignore_sideways_crush = false; | ||
} | ||
else { | ||
kill(true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we make it so that despite of the side where Tux was hit from, kill(false)
is performed? Is there a reason for sideways crushing to instantly kill Tux with kill(true)
?
If we do that, m_ignore_sideways_crush
wouldn't be needed.
This also includes some code style improvements to the
Crusher::collision
and relieves some of the mental pain I have when looking at the SuperTux source code.Fixes #3024