Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
vor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
found another place where it said 0.5.1
[vor.git]
/
sprite.h
diff --git
a/sprite.h
b/sprite.h
index
953d303
..
c95db83
100644
(file)
--- a/
sprite.h
+++ b/
sprite.h
@@
-8,13
+8,14
@@
typedef struct sprite Sprite;
#define SPRITE(x) ((Sprite *) (x))
#define SPRITE(x) ((Sprite *) (x))
-#define BASE_SPRITE 0
-#define SHIP_SPRITE 1
-#define ROCK_SPRITE 2
+#define BASE 0
+#define SHIP 1
+#define ROCK 2
#define N_TYPES 3
struct sprite {
int8_t type;
#define N_TYPES 3
struct sprite {
int8_t type;
+ int8_t flags;
Sprite *next;
float x, y;
float dx, dy;
Sprite *next;
float x, y;
float dx, dy;
@@
-22,19
+23,32
@@
struct sprite {
int w, h;
int mask_w;
uint32_t *mask;
int w, h;
int mask_w;
uint32_t *mask;
+ uint32_t area;
};
};
+// flags
+#define MOVE 1
+#define DRAW 2
+#define COLLIDE 4
+
+#define COLLIDES(sprite) ((sprite)->flags & COLLIDE)
+
Sprite *free_sprites[N_TYPES]; // lists of free sprites, by type.
Sprite *free_sprites[N_TYPES]; // lists of free sprites, by type.
+void do_collision(Sprite *a, Sprite *b);
+void collisions(void);
+
void init_sprites(void);
void init_sprites(void);
+void reset_sprites(void);
void add_sprite(Sprite *s);
void move_sprite(Sprite *s);
void move_sprites(void);
Sprite *collides(Sprite *s);
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);
void load_sprite(Sprite *sprite, char *filename);
+float sprite_mass(Sprite *s);
void bounce(Sprite *a, Sprite *b);
void bounce(Sprite *a, Sprite *b);
@@
-43,6
+57,7
@@
void bounce(Sprite *a, Sprite *b);
struct ship {
// core sprite fields
int8_t sprite_type;
struct ship {
// core sprite fields
int8_t sprite_type;
+ int8_t flags;
struct ship *next;
float x, y;
float dx, dy;
struct ship *next;
float x, y;
float dx, dy;
@@
-50,6
+65,7
@@
struct ship {
int w, h;
int mask_w;
uint32_t *mask;
int w, h;
int mask_w;
uint32_t *mask;
+ uint32_t area;
// SHIP extras
int lives;
int jets;
// SHIP extras
int lives;
int jets;
@@
-58,6
+74,7
@@
struct ship {
struct rock {
// core sprite fields
int8_t sprite_type;
struct rock {
// core sprite fields
int8_t sprite_type;
+ int8_t flags;
struct rock *next;
float x, y;
float dx, dy;
struct rock *next;
float x, y;
float dx, dy;
@@
-65,6
+82,7
@@
struct rock {
int w, h;
int mask_w;
uint32_t *mask;
int w, h;
int mask_w;
uint32_t *mask;
+ uint32_t area;
// ROCK extras
int type;
};
// ROCK extras
int type;
};
@@
-92,9
+110,10
@@
static inline void
draw_sprite(Sprite *s)
{
SDL_Rect dest;
draw_sprite(Sprite *s)
{
SDL_Rect dest;
- if(s->type == NONE) 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
}
#endif // VOR_SPRITE_H