JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
ditched the separate shape struct.
[vor.git] / sprite.h
index 939de08..7df8631 100644 (file)
--- a/sprite.h
+++ b/sprite.h
@@ -4,73 +4,62 @@
 #include <SDL.h>
 #include <inttypes.h>
 
-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);