franzenzenhofer / lsd

LSD - line-square-dot: an addicting game
159 stars 17 forks source link

Collision #2

Open myozka opened 9 years ago

myozka commented 9 years ago

Dot-Line collision causes the dot to be skewered sometimes.

If I have time these days, I will create a pull request for it too.

rolandschuetz commented 9 years ago

I can confirm the issue: http://screencast.com/t/hlmNt69d

franzenzenhofer commented 9 years ago

yeah, known issue. thing is i calculate the collision between the dot and a vector (line). and there will always be edge cases

so the bug is here https://github.com/franzenzenhofer/lsd/blob/gh-pages/main.coffee#L350-L367

so either i can check if the line is intersection the dot, then i just move the dot a little bit somewhere (minus the -y-velocity) until it isn't - this is cheating

or just stop treating the dot as a dot and treat it like a vector. meaning: take the dot where it now is, take the dot where it will be on the next tick. see if this line intersects other line, if yes, it was a collision.

something like that

myozka commented 9 years ago

It is a better way to do that. ( treating the dot as vector of last location to current location).

The dirty trick you said also can be applied, it is easy and doesn't harm the process as long as you do it according to (velocity vector x 1%) etc.

franzenzenhofer commented 9 years ago

@myozka

if you could help with either one of those (first the dirty trick one) would be really appreciated, I'm not sure what to do, a pointer in the right direction would also be appreciated