X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=shape.c;h=f29bd6ed0a6edcbb59d68d4b784a193f71ee757e;hp=f45715866b11a44473c9a788f4a61fe591286e7d;hb=cd7fb220b16a73c15ff9dff7a5627bf78478875f;hpb=30498ebe775df3854f28946b1373da948bd190a3 diff --git a/shape.c b/shape.c index f457158..f29bd6e 100644 --- a/shape.c +++ b/shape.c @@ -7,7 +7,7 @@ get_shape(SDL_Surface *img, struct shape *s) { int x, y; uint16_t *px, transp; - uint32_t bits, bit, *p; + uint32_t bits = 0, bit, *p; if(img->format->BytesPerPixel != 2) { fprintf(stderr, "get_shape(): not a 16-bit image!\n"); @@ -108,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; +}