-
Notifications
You must be signed in to change notification settings - Fork 142
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
Simplify collision detection to avoid punching tunnels #32
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
this fixes the tunneling, but without the bounce changing, i think it loses a lot of the pong-ness |
To reintroduce speed/angle randomisation, you can locally revert 674e095 from main |
The code is definitely clearer, doing a long running test right to see if the balls ever get stuck. |
index.html
Outdated
let i = Math.floor(x / SQUARE_SIZE); | ||
let j = Math.floor(y / SQUARE_SIZE); | ||
let ci = Math.floor(checkX / SQUARE_SIZE); | ||
let cj = Math.floor(checkY / SQUARE_SIZE); |
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.
Could we have a more descriptive variable name for ci and cj?
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.
Are checkI
and checkJ
OK?
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.
How about column and row for i and j and nextRow and nextColumn for ci and cj?
I believe this does not work yet. Collision speed offWhile the squares are bound to a grid the balls are not, so the balls center are not always at the center of a square. Collision that works correctly: Collision that does not work correctly: Collision as pointBy evaluating the next column with Diagonal collisionsThe collision function only checks for collisions in neighbors. If a ball approaches diagonally towards a corner the collision is not correct. [2][3] |
Any plans to adopt the simplified collision detection code? |
Resolves #1