Skip to content

Fix heavy coins ignoring water physics (Closes #3729)#3771

Open
franciscogfsm wants to merge 6 commits intoSuperTux:masterfrom
franciscogfsm:fix/heavy-coin-water-physics
Open

Fix heavy coins ignoring water physics (Closes #3729)#3771
franciscogfsm wants to merge 6 commits intoSuperTux:masterfrom
franciscogfsm:fix/heavy-coin-water-physics

Conversation

@franciscogfsm
Copy link
Copy Markdown

Fix #3729: Heavy coins not affected by water physics

Heavy coins (and coins dropped by killed enemies) were not applying
water physics when falling into water, causing them to sink straight
to the bottom at full speed instead of floating like other objects.

Fixed by adding a per-frame water tile check in HeavyCoin::update().
When the coin is detected inside a water tile:

  • Gravity modifier is reduced to 0.1
  • Downward velocity is capped at 100

This matches the floaty behaviour of other physics objects such as
rocks and enemies. Named constants are used for both water physics
values to avoid magic numbers.

Tested manually by dropping heavy coins and enemy-dropped coins into
water both now float as expected. Automated tests have also been
implemented covering the fix.

Closes #3729

Heavy coins (and coins dropped by killed enemies) were not applying
water physics when falling into water, causing them to sink straight
to the bottom at full speed instead of becoming floaty.
Fixed by adding a per-frame water tile check in HeavyCoin::update().
When the coin is detected inside a water tile, the gravity modifier is
reduced to 0.1 and the downward velocity is capped at 100, matching
the floaty behaviour of other physics objects like rocks and enemies.

Use named constants for water physics values

Testing Implemented for the Bug Fix
@swagtoy
Copy link
Copy Markdown
Member

swagtoy commented Apr 7, 2026

Hello, just curious which AI model you used for this?

@franciscogfsm
Copy link
Copy Markdown
Author

Hey what do you think its wrong apart from the tests so i can improve ?

@swagtoy
Copy link
Copy Markdown
Member

swagtoy commented Apr 13, 2026

Did you utilize an LLM to make this contribution? You did not answer that.

What I think is wrong is the test cases existing in the first place: we got a slew of contributions making test cases for game logic. We don't desire unit tests for physics like this because we sometimes also change these things based on the eye (and tbh, they are kind of redundant...), thus we can't honestly maintain tests like that.

@franciscogfsm
Copy link
Copy Markdown
Author

Hey, yeah I used AI for the comments, english is not my main language so i used it just to be clear about what changed and why. I totally get the issue with the tests. The actual fix I wrote and tested manually myself, heavy coins now float in water as expected, i am just slowing down the gravity and checking if its a water tile, in terms of performance i also don't think its an issue. Thank you for your feedback hope we can close this.

@franciscogfsm
Copy link
Copy Markdown
Author

Hey, i have removed the unecessary files, now is just the gravity tweak.

Comment thread tests/unit/CMakeLists.txt Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please restore this file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. File Restored

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you restored the wrong file... :)

You can try doing a git revert for that one.

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.

[Bug]: Coin gravity not affected by water

3 participants