Revision 236
improved bullet stuff
ent.c | ||
---|---|---|
101 | 101 |
} |
102 | 102 |
|
103 | 103 |
struct bullet{ |
104 |
const gunner_t *shooter; |
|
104 | 105 |
double x, y; //real position |
105 | 106 |
double vx, vy; |
106 | 107 |
sprite_t *b; |
107 | 108 |
int damage; |
108 | 109 |
}; |
109 |
bullet_t* (bullet_ctor)(basic_sprite_t *b, double x, double y, double vx, double vy){ |
|
110 |
bullet_t* (bullet_ctor)(const gunner_t *shooter, basic_sprite_t *b, double x, double y, double vx, double vy){
|
|
110 | 111 |
bullet_t *ret = malloc(sizeof(bullet_t)); |
111 | 112 |
if(ret == NULL) return NULL; |
113 |
ret->shooter = shooter; |
|
112 | 114 |
ret-> x = x; |
113 | 115 |
ret-> y = y; |
114 | 116 |
ret->vx = vx; |
... | ... | |
246 | 248 |
} |
247 | 249 |
|
248 | 250 |
int (gunner_collides_bullet)(const gunner_t *shooter, const bullet_t *bull){ |
251 |
if(bull->shooter == shooter) return false; |
|
252 |
|
|
249 | 253 |
double shooter_radius = max(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0; |
250 | 254 |
double shooter_x = gunner_get_x(shooter); |
251 | 255 |
double shooter_y = gunner_get_y(shooter); |
Also available in: Unified diff