X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=shape.c;h=92914cbb254b58d3639e92dde8610e1324ae15a1;hp=9d0501c24485ae6539af2c340b2daf1efee38fc6;hb=2bea0659b8edff14f1554d2540780f54ccdc21c9;hpb=8193e09e49bc571f9c61e6e3adf45010271c08d5 diff --git a/shape.c b/shape.c index 9d0501c..92914cb 100644 --- a/shape.c +++ b/shape.c @@ -52,12 +52,11 @@ collide(int xdiff, int ydiff, struct shape *r, struct shape *s) int xov, yov; if(xdiff >= 0) xov = max(min(r->w-xdiff, s->w), 0); - else xov = -max(min(s->w+xdiff, r->w), 0); + else xov = min(-min(s->w+xdiff, r->w), 0); if(ydiff >= 0) yov = max(min(r->h-ydiff, s->h), 0); - else yov = -max(min(s->h+ydiff, r->h), 0); + else yov = min(-min(s->h+ydiff, r->h), 0); - if(xov == 0 && yov == 0) return 0; - - return 0; + if(xov == 0 || yov == 0) return 0; // bboxes hit? + else return 1; }