From: Joshua Grams Date: Sat, 25 Mar 2006 21:16:48 +0000 (+0000) Subject: proper moving-away detection in bounce()? X-Git-Tag: 0.4~11 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=37b3a2e06abc694205e843a573c4bb2eaaabb730 proper moving-away detection in bounce()? --- diff --git a/sprite.c b/sprite.c index e63fd68..1a35a6a 100644 --- a/sprite.c +++ b/sprite.c @@ -349,8 +349,9 @@ bounce(Sprite *a, Sprite *b) n = sqrt(x*x + y*y); x /= n; y /= n; // velocities along (x, y), or 0 if already moving away. - va = max(x*a->dx + y*a->dy, 0); - vb = min(x*b->dx + y*b->dy, 0); + va = x*a->dx + y*a->dy; + vb = x*b->dx + y*b->dy; + if(vb-va > 0) return; ma = sprite_mass(a); mb = sprite_mass(b); vc = (va*ma + vb*mb) / (ma+mb);