X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=sprite.h;h=7df8631ac846214f232a898cfce06bd0bcbe34ff;hp=939de0855470e2a7b41161e3be626bf8d18f8073;hb=3f9238432d3b902a7744ad5a61f61995d67267a5;hpb=f8a464d8eed8cf611c0c3f80166d2a650efb1485 diff --git a/sprite.h b/sprite.h index 939de08..7df8631 100644 --- a/sprite.h +++ b/sprite.h @@ -4,73 +4,62 @@ #include #include -typedef union sprite Sprite; +typedef struct sprite Sprite; +#define SPRITE(x) ((Sprite *) (x)) -// Shape stuff +#define BASE_SPRITE 0 +#define SHIP_SPRITE 1 +#define ROCK_SPRITE 2 -struct shape { +struct sprite { + uint8_t type; + Sprite *next; + float x, y; + float dx, dy; + SDL_Surface *image; int w, h; - int mw; // mask width (number of uint32's) + int mask_w; uint32_t *mask; - uint32_t area; }; -void get_shape(SDL_Surface *img, struct shape *s); +void get_shape(Sprite *s); int collide(Sprite *r, Sprite *s); -int pixel_collide(unsigned int xdiff, unsigned int ydiff, struct shape *r); +int pixel_collide(Sprite *s, int x, int y); -// Sprite stuff - -#define SPRITE(x) ((Sprite *) (x)) +// extended sprites -struct base_sprite { - uint8_t type; - Sprite *next; +struct ship { + // core sprite fields + uint8_t sprite_type; + struct ship *next; float x, y; float dx, dy; SDL_Surface *image; - struct shape *shape; + int w, h; + int mask_w; + uint32_t *mask; + // SHIP extras + int lives; + int jets; }; struct rock { // core sprite fields uint8_t sprite_type; - Sprite *next; + struct rock *next; float x, y; float dx, dy; SDL_Surface *image; - struct shape *shape; + int w, h; + int mask_w; + uint32_t *mask; // ROCK extras int type; }; -struct ship { - // core sprite fields - uint8_t sprite_type; - Sprite *next; - float x, y; - float dx, dy; - SDL_Surface *image; - struct shape *shape; - // SHIP extras - int lives; - int jets; -}; - -union sprite { - uint8_t type; - struct base_sprite sprite; - struct rock rock; - struct ship ship; -}; - -#define BASE_SPRITE 0 -#define SHIP_SPRITE 1 -#define ROCK_SPRITE 2 - SDL_Surface *load_image(char *filename); void load_sprite(Sprite *sprite, char *filename);