-
Notifications
You must be signed in to change notification settings - Fork 132
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
Fix Issue #82 - Pushed boulder can collide with pusher #159
base: barony-next
Are you sure you want to change the base?
Fix Issue #82 - Pushed boulder can collide with pusher #159
Conversation
Update to Latest Code
…r push collision checks
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.
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
I agree, I guess I didn't consider that after finally figuring out the issue. All fixed now! |
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.
Much nicer! I haven't tested it though so this is only approval of the code itself.
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.