Revision 201
renamed gunner
ent.c | ||
---|---|---|
15 | 15 |
double (ent_get_XLength)(void){ return graph_get_XRes()/scale; } |
16 | 16 |
double (ent_get_YLength)(void){ return graph_get_YRes()/scale; } |
17 | 17 |
|
18 |
struct ent{
|
|
18 |
struct gunner{
|
|
19 | 19 |
double x, y; //real position in meters |
20 | 20 |
sprite_t *dude; |
21 | 21 |
sprite_t *weapon; |
22 | 22 |
}; |
23 | 23 |
|
24 |
ent_t* (ent_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon){
|
|
25 |
ent_t *ret = malloc(sizeof(ent_t));
|
|
24 |
gunner_t* (gunner_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon){
|
|
25 |
gunner_t *ret = malloc(sizeof(gunner_t));
|
|
26 | 26 |
if(ret == NULL) return NULL; |
27 | 27 |
ret->x = 0.0; |
28 | 28 |
ret->y = 0.0; |
29 | 29 |
ret->dude = sprite_ctor(dude ); |
30 | 30 |
ret->weapon = sprite_ctor(weapon); |
31 | 31 |
if(ret->dude == NULL || ret->weapon == NULL){ |
32 |
ent_dtor(ret);
|
|
32 |
gunner_dtor(ret);
|
|
33 | 33 |
return NULL; |
34 | 34 |
} else return ret; |
35 | 35 |
} |
36 |
void (ent_dtor)(ent_t *p){
|
|
36 |
void (gunner_dtor)(gunner_t *p){
|
|
37 | 37 |
if(p == NULL) return; |
38 | 38 |
sprite_dtor(p->dude); |
39 | 39 |
sprite_dtor(p->weapon); |
40 | 40 |
free(p); |
41 | 41 |
} |
42 | 42 |
|
43 |
void (ent_set_pos) (ent_t *p, int16_t x, int16_t y){ p->x = x; p->y = y; }
|
|
44 |
void (ent_set_angle)(ent_t *p, double angle ){
|
|
43 |
void (gunner_set_pos) (gunner_t *p, int16_t x, int16_t y){ p->x = x; p->y = y; }
|
|
44 |
void (gunner_set_angle)(gunner_t *p, double angle ){
|
|
45 | 45 |
sprite_set_angle(p->dude , angle); |
46 | 46 |
sprite_set_angle(p->weapon, angle); |
47 | 47 |
} |
48 | 48 |
|
49 |
double (ent_get_x) (const ent_t *p){ return p->x; }
|
|
50 |
double (ent_get_y) (const ent_t *p){ return p->y; }
|
|
51 |
int16_t (ent_get_x_screen)(const ent_t *p){ return (p->x-x_origin)*scale; }
|
|
52 |
int16_t (ent_get_y_screen)(const ent_t *p){ return (p->y-y_origin)*scale; }
|
|
49 |
double (gunner_get_x) (const gunner_t *p){ return p->x; }
|
|
50 |
double (gunner_get_y) (const gunner_t *p){ return p->y; }
|
|
51 |
int16_t (gunner_get_x_screen)(const gunner_t *p){ return (p->x-x_origin)*scale; }
|
|
52 |
int16_t (gunner_get_y_screen)(const gunner_t *p){ return (p->y-y_origin)*scale; }
|
|
53 | 53 |
|
54 |
void (ent_draw)(ent_t *p){
|
|
55 |
const int16_t x_screen = ent_get_x_screen(p);
|
|
56 |
const int16_t y_screen = ent_get_y_screen(p);
|
|
54 |
void (gunner_draw)(gunner_t *p){
|
|
55 |
const int16_t x_screen = gunner_get_x_screen(p);
|
|
56 |
const int16_t y_screen = gunner_get_y_screen(p);
|
|
57 | 57 |
sprite_set_pos (p->dude , x_screen, y_screen); |
58 | 58 |
sprite_set_pos (p->weapon, x_screen, y_screen); |
59 | 59 |
sprite_set_scale(p->dude , scale); |
Also available in: Unified diff