X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=sprite.c;h=db5ac8d3c5b9a3b80109e478ab41e3aeaf8b225e;hp=1609368d324ab653070e6315e90d75b2260ed774;hb=0978da8f14d855eecae9882b559d6e8b0533e78e;hpb=e06676edd300c8a85d2e6715427e7e22e55c7670 diff --git a/sprite.c b/sprite.c index 1609368..db5ac8d 100644 --- a/sprite.c +++ b/sprite.c @@ -111,7 +111,6 @@ square(int x, int y, int set) void add_sprite(Sprite *s) { - if(s->type < 0) s->type = -s->type; insert_sprite(square(s->x, s->y, set), s); } @@ -123,18 +122,19 @@ reset_sprites(void) for(i=0; itype < 0) s->type = -s->type; insert_sprite(&free_sprites[s->type], s); - if(s->type > 0) s->type = -s->type; + s->flags = 0; } } void move_sprite(Sprite *s) { - // move it. - s->x += (s->dx - screendx)*t_frame; - s->y += (s->dy - screendy)*t_frame; + if(s->flags & DRAW_FLAG) { + // move it. + s->x += (s->dx - screendx)*t_frame; + s->y += (s->dy - screendy)*t_frame; + } } void @@ -143,9 +143,8 @@ sort_sprite(Sprite *s) // clip it, or sort it into the other set of sprites. if(s->x + s->w < 0 || s->x >= XSIZE || s->y + s->h < 0 || s->y >= YSIZE) { - if(s->type < 0) s->type = -s->type; insert_sprite(&free_sprites[s->type], s); - if(s->type > 0) s->type = -s->type; + s->flags = 0; } else insert_sprite(square(s->x, s->y, 1-set), s); } @@ -214,7 +213,7 @@ collide(Sprite *a, Sprite *b) { int dx, dy, xov, yov; - if(a->type < 0 || b->type < 0) return false; + if(!COLLIDES(a) || !COLLIDES(b)) return false; if(b->x < a->x) { Sprite *tmp = a; a = b; b = tmp; } @@ -306,7 +305,7 @@ int pixel_hit_in_square(Sprite *r, float x, float y) { for(; r; r=r->next) { - if(r->type >= 0 && pixel_collide(r, x, y)) return 1; + if(COLLIDES(r) && pixel_collide(r, x, y)) return 1; } return 0; }