Project

General

Profile

Revision 302

working on zombies

View differences:

ent.c
24 24
    sprite_t *weapon;
25 25
    double health, current_health;
26 26
    gunner_type type;
27
    int team;
27 28
};
28
gunner_t* (gunner_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon, gunner_type tp){
29
gunner_t* (gunner_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon, gunner_type type, int team){
29 30
    gunner_t *ret = malloc(sizeof(gunner_t));
30 31
    if(ret == NULL) return NULL;
31 32
    ret->spawn_x = 0.0;
......
34 35
    ret->y = 0.0;
35 36
    ret->health = 100;
36 37
    ret->current_health = ret->health;
37
    ret->type = tp;
38
    ret->type = type;
39
    ret->team = team;
38 40
    ret->dude   = sprite_ctor(dude  );
39 41
    ret->weapon = sprite_ctor(weapon);
40 42
    if(ret->dude == NULL || ret->weapon == NULL){
......
72 74
int16_t (gunner_get_x_screen)       (const gunner_t *p){ return (p->x-x_origin)*scale; }
73 75
int16_t (gunner_get_y_screen)       (const gunner_t *p){ return (p->y-y_origin)*scale; }
74 76
gunner_type (gunner_get_type)       (const gunner_t *p){ return p->type; }
77
int     (gunner_get_team)           (const gunner_t *p){ return p->team; }
75 78
void (gunner_draw)(gunner_t *p){
76 79
    const int16_t x_screen = gunner_get_x_screen(p);
77 80
    const int16_t y_screen = gunner_get_y_screen(p);
......
102 105
    rectangle_dtor(red_bar);
103 106
}
104 107

  
108
double (gunner_distance)(const gunner_t *p1, const gunner_t *p2){
109
    double dx = gunner_get_x(p1) - gunner_get_x(p2);
110
    double dy = gunner_get_y(p1) - gunner_get_y(p2);
111
    return sqrt(dx*dx+dy*dy);
112
}
113

  
105 114
struct bullet{
106 115
    const gunner_t *shooter;
107 116
    double x, y; //real position
......
141 150
    if (damage < 0) damage = 0;
142 151
    p->damage = damage;
143 152
}
153
const gunner_t* (bullet_get_shooter)(const bullet_t *p){ return p->shooter; }
144 154
void (bullet_update_movement)(bullet_t *p){
145 155
    p->x += p->vx;
146 156
    p->y += p->vy;

Also available in: Unified diff