From 37b3a2e06abc694205e843a573c4bb2eaaabb730 Mon Sep 17 00:00:00 2001 From: Joshua Grams Date: Sat, 25 Mar 2006 21:16:48 +0000 Subject: [PATCH 1/1] proper moving-away detection in bounce()? --- sprite.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); -- 1.7.10.4