JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Friction doesn't make sense any more, dropped that.
[vor.git] / shape.c
diff --git a/shape.c b/shape.c
index 867610e..f457158 100644 (file)
--- a/shape.c
+++ b/shape.c
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include "common.h"
 #include "shape.h"
 
 void
@@ -13,6 +14,7 @@ get_shape(SDL_Surface *img, struct shape *s)
                exit(1);
        }
 
+       s->area = 0;
        s->w = img->w; s->h = img->h;
        s->mw = ((img->w+31)>>5);
        s->mask = malloc(4*s->mw*s->h);
@@ -29,7 +31,7 @@ get_shape(SDL_Surface *img, struct shape *s)
                bit = 0;
                for(x=0; x<img->w; x++) {
                        if(!bit) { bits = 0; bit = 0x80000000; }
-                       if(*px++ != transp) bits |= bit;
+                       if(*px++ != transp) { bits |= bit; s->area++; }
                        bit >>= 1;
                        if(!bit || x == img->w - 1) { *(p++) = bits; }
                }
@@ -38,18 +40,6 @@ get_shape(SDL_Surface *img, struct shape *s)
        SDL_UnlockSurface(img);
 }
 
-#ifndef max
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef abs
-#define abs(a) ((a)<=0 ? -(a) : (a))
-#endif
-
 int
 line_collide(int xov, struct shape *r, uint32_t *rbits, struct shape *s, uint32_t *sbits)
 {