X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=sprite.h;h=04450775307d011776401d696c3da97c828be1ce;hp=f9070b43141a8479668e4ed3de792b01d220789a;hb=HEAD;hpb=e06676edd300c8a85d2e6715427e7e22e55c7670 diff --git a/sprite.h b/sprite.h index f9070b4..d67b655 100644 --- a/sprite.h +++ b/sprite.h @@ -15,6 +15,7 @@ typedef struct sprite Sprite; struct sprite { int8_t type; + int8_t flags; Sprite *next; float x, y; float dx, dy; @@ -25,7 +26,14 @@ struct sprite { uint32_t area; }; -Sprite *free_sprites[N_TYPES]; // lists of free sprites, by type. +// flags +#define MOVE 1 +#define DRAW 2 +#define COLLIDE 4 + +#define COLLIDES(sprite) ((sprite)->flags & COLLIDE) + +extern Sprite *free_sprites[N_TYPES]; // lists of free sprites, by type. void do_collision(Sprite *a, Sprite *b); void collisions(void); @@ -36,10 +44,10 @@ void add_sprite(Sprite *s); void move_sprite(Sprite *s); void move_sprites(void); -Sprite *collides(Sprite *s); -int pixel_collides(float x, float y); +Sprite * pixel_collides(float x, float y); void load_sprite(Sprite *sprite, char *filename); +float sprite_mass(Sprite *s); void bounce(Sprite *a, Sprite *b); @@ -48,6 +56,7 @@ void bounce(Sprite *a, Sprite *b); struct ship { // core sprite fields int8_t sprite_type; + int8_t flags; struct ship *next; float x, y; float dx, dy; @@ -64,6 +73,7 @@ struct ship { struct rock { // core sprite fields int8_t sprite_type; + int8_t flags; struct rock *next; float x, y; float dx, dy; @@ -74,6 +84,7 @@ struct rock { uint32_t area; // ROCK extras int type; + int life; }; @@ -99,9 +110,10 @@ static inline void draw_sprite(Sprite *s) { SDL_Rect dest; - if(s->type < 0) return; - dest.x = s->x; dest.y = s->y; - SDL_BlitSurface(s->image, NULL, surf_screen, &dest); + if(s->flags & DRAW) { + dest.x = s->x; dest.y = s->y; + SDL_BlitSurface(s->image, NULL, surf_screen, &dest); + } } #endif // VOR_SPRITE_H