Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Various crusher fixes #3047

wants to merge 5 commits into from

Conversation

tobbi
Copy link
Member

@tobbi tobbi commented Aug 21, 2024

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

@bruhmoent
Copy link
Member

Will test tm.

@tobbi tobbi changed the title Hurt player when hit by a sideways crusher instead of killing Various crusher fixed Aug 27, 2024
@tobbi tobbi changed the title Various crusher fixed Various crusher fixes Aug 27, 2024
@tobbi
Copy link
Member Author

tobbi commented Aug 27, 2024

I've added a fix for an issue found by frost, where roots would spawn in the wrong direction.

@tobbi
Copy link
Member Author

tobbi commented Aug 28, 2024

@bruhmoent Could you test as well?

@bruhmoent
Copy link
Member

Yes. I will soon.

Copy link
Member

@bruhmoent bruhmoent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested

@tobbi
Copy link
Member Author

tobbi commented Aug 30, 2024

I moved some code out but I don't know what phase_factor or amplitude do. So, well...

@tobbi
Copy link
Member Author

tobbi commented Sep 22, 2024

@Vankata453 @MatusGuy Can you guys test the code changes and merge maybe?

Comment on lines +2328 to +2334
if ((hit.left || hit.right)) {
if (m_ignore_sideways_crush) {
m_ignore_sideways_crush = false;
}
else {
kill(true);
}
Copy link
Member

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

Comment on lines +655 to +675
{
// 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.
}
Copy link
Member

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.

Copy link
Member

@Vankata453 Vankata453 left a 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.

Comment on lines 132 to 133
// If the other object is the player, and the collision is at the
// bottom of the crusher, hurt the player.
Copy link
Member

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).

Comment on lines +2328 to +2334
if ((hit.left || hit.right)) {
if (m_ignore_sideways_crush) {
m_ignore_sideways_crush = false;
}
else {
kill(true);
}
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sideways Crusher should not insta-kill players
5 participants