JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
* rocks.c (struct rock): changed generic ones to Sprite.
[vor.git] / sprite.h
1 #ifndef VOR_SHAPE_H
2 #define VOR_SHAPE_H
3
4 #include <SDL.h>
5 #include <inttypes.h>
6
7 typedef struct sprite Sprite;
8
9 #define SPRITE(x) ((Sprite *) (x))
10
11 #define BASE_SPRITE 0
12 #define SHIP_SPRITE 1
13 #define ROCK_SPRITE 2
14
15 struct sprite {
16         uint8_t type;
17         Sprite *next;
18         float x, y;
19         float dx, dy;
20         SDL_Surface *image;
21         int w, h;
22         int mask_w;
23         uint32_t *mask;
24 };
25
26 void get_shape(Sprite *s);
27 int collide(Sprite *r, Sprite *s);
28 int pixel_collide(Sprite *s, int x, int y);
29
30
31
32 // extended sprites
33
34 struct ship {
35         // core sprite fields
36         uint8_t sprite_type;
37         struct ship *next;
38         float x, y;
39         float dx, dy;
40         SDL_Surface *image;
41         int w, h;
42         int mask_w;
43         uint32_t *mask;
44         // SHIP extras
45         int lives;
46         int jets;
47 };
48
49 struct rock {
50         // core sprite fields
51         uint8_t sprite_type;
52         struct rock *next;
53         float x, y;
54         float dx, dy;
55         SDL_Surface *image;
56         int w, h;
57         int mask_w;
58         uint32_t *mask;
59         // ROCK extras
60         int type;
61 };
62
63 SDL_Surface *load_image(char *filename);
64 void load_sprite(Sprite *sprite, char *filename);
65
66 #endif // VOR_SHAPE_H