Fix Issue #82 - Pushed boulder can collide with pusher#159
Open
crkellen wants to merge 7 commits intoTurningWheel:barony-nextfrom
Open
Fix Issue #82 - Pushed boulder can collide with pusher#159crkellen wants to merge 7 commits intoTurningWheel:barony-nextfrom
crkellen wants to merge 7 commits intoTurningWheel:barony-nextfrom
Conversation
added 6 commits
August 13, 2017 18:31
Update to Latest Code
…r push collision checks
This was referenced Aug 18, 2017
lheckemann
suggested changes
Sep 24, 2017
Contributor
lheckemann
left a comment
There was a problem hiding this comment.
A lot of new duplication against boulderCheckAgainstEntity. Indeed, the functions are identical besides the distinction between entityInFrontOfEntity/entityInsideEntity. Common functionality should be factored out.
But I am really looking forward to not dying in Sokoban xD
Contributor
Author
|
I agree, I guess I didn't consider that after finally figuring out the issue. All fixed now! |
lheckemann
approved these changes
Sep 28, 2017
Contributor
lheckemann
left a comment
There was a problem hiding this comment.
Much nicer! I haven't tested it though so this is only approval of the code itself.
SheridanR
pushed a commit
that referenced
this pull request
Mar 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for #82.
The issue is twofold:
Boulders pushing movement is calculated expected a perfect resolution. It uses truncation (floor()) in it's calculations, which cause it to be fixed to grid positions (only moves in increments of 16). This is only a problem when the boulder collides with something like another boulder (or other Entity), because the boulder will be somewhere in between the increment of 16. When a push happens after that, the floor() calculation causes the boulder to jump back to it's correct position (starting position). The player may be standing within that starting position, which causes the boulder to collide and hurt the one pushing.
Calculations for collisions with boulders is done using 'entityInsideEntity()'. This is a simple AABB bounding box collision check, which allows for a collision to occur from the opposite direction than the boulder is rolling. The solution is to implement 'entityInFrontOfEntity()' which, for each direction, avoids the possibility of colliding in the direction opposite of movement.
So, the collision is completely fixed, however there are still a few things left to sort out with boulders:
These will be solved in future pull requests.