Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
vor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* rocks.c (init_buckets): oops, we weren't allocating big enough arrays.
[vor.git]
/
shape.c
diff --git
a/shape.c
b/shape.c
index
9e03f19
..
f29bd6e
100644
(file)
--- a/
shape.c
+++ b/
shape.c
@@
-1,4
+1,5
@@
#include <stdlib.h>
#include <stdlib.h>
+#include "common.h"
#include "shape.h"
void
#include "shape.h"
void
@@
-6,7
+7,7
@@
get_shape(SDL_Surface *img, struct shape *s)
{
int x, y;
uint16_t *px, transp;
{
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");
if(img->format->BytesPerPixel != 2) {
fprintf(stderr, "get_shape(): not a 16-bit image!\n");
@@
-39,18
+40,6
@@
get_shape(SDL_Surface *img, struct shape *s)
SDL_UnlockSurface(img);
}
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)
{
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);
}
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;
+}