X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=shape.c;h=75424ef9ed104e9468e7306e21a0df264b113dba;hp=9e03f19a49f395dd47eefad595fed200313783bd;hb=2b5dd5bc0eb1739dd744de6f565d0f3a7ae02c95;hpb=46dacbe75dac20a1c6e1b61a2eb99ca25fc971ec diff --git a/shape.c b/shape.c index 9e03f19..75424ef 100644 --- a/shape.c +++ b/shape.c @@ -1,4 +1,5 @@ #include +#include "common.h" #include "shape.h" void @@ -39,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) { @@ -119,3 +108,14 @@ collide(int xdiff, int ydiff, struct shape *r, struct shape *s) if(xov == 0 || yov == 0) return 0; // bboxes hit? else return mask_collide(xov, yov, r, s); } + +int +pixel_collide(unsigned int xoff, unsigned int yoff, struct shape *r) +{ + uint32_t pmask; + + if(xoff >= r->w || yoff >= r->h) return 0; + + pmask = 0x80000000 >> (xoff&0x1f); + return r->mask[(yoff*r->mw) + (xoff>>5)] & pmask; +}