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

Fix Issue #82 - Pushed boulder can collide with pusher #159

Open
wants to merge 7 commits into
base: barony-next
Choose a base branch
from

Conversation

crkellen
Copy link
Contributor

This is a fix for #82.
The issue is twofold:

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

  2. 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:

  • Clients do not have accurate positions of boulders (constantly vibrating if not against a wall/entity)
  • Boulders have a size that is 1 unit less than their actual radius. This allows for them to be partially inside of another Entity, such as another boulder, which causes a visual issue of the boulder jumping back when the floor() calculations are done.

These will be solved in future pull requests.

Copy link
Contributor

@lheckemann lheckemann left a 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

@crkellen
Copy link
Contributor Author

I agree, I guess I didn't consider that after finally figuring out the issue. All fixed now!

Copy link
Contributor

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

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.

2 participants