Project

General

Profile

Revision 232

death of shooters

View differences:

proj/include/ent.h
16 16
gunner_t* (gunner_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon);
17 17
void      (gunner_dtor)(gunner_t *p);
18 18
void (gunner_set_pos)               (gunner_t *p, double x, double y);
19
void  (gunner_set_spawn)        (gunner_t *p, double x, double y);
19 20
void (gunner_set_angle)             (gunner_t *p, double angle      );
20 21
void (gunner_set_health)            (gunner_t *p, int health);
21 22
void (gunner_set_curr_health)       (gunner_t *p, int health);
22 23
double  (gunner_get_x)              (const gunner_t *p);
23 24
double  (gunner_get_y)              (const gunner_t *p);
25
double  (gunner_get_spawn_x)        (const gunner_t *p);
26
double  (gunner_get_spawn_y)        (const gunner_t *p);
24 27
double  (gunner_get_angle)          (const gunner_t *p);
25 28
int     (gunner_get_health)         (const gunner_t *p);
26 29
int     (gunner_get_curr_health)    (const gunner_t *p);
proj/src/ent.c
20 20

  
21 21
struct gunner{
22 22
    double x, y; //real position
23
    double spawn_x, spawn_y;
23 24
    sprite_t *dude;
24 25
    sprite_t *weapon;
25 26
    int health, current_health;
......
27 28
gunner_t* (gunner_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon){
28 29
    gunner_t *ret = malloc(sizeof(gunner_t));
29 30
    if(ret == NULL) return NULL;
31
    ret->spawn_x = 0.0;
32
    ret->spawn_y = 0.0;
30 33
    ret->x = 0.0;
31 34
    ret->y = 0.0;
32 35
    ret->health = 100;
......
45 48
    free(p);
46 49
}
47 50
void (gunner_set_pos)  (gunner_t *p, double x, double y){ p->x = x; p->y = y; }
51
void (gunner_set_spawn)  (gunner_t *p, double x, double y){ p->spawn_x = x; p->spawn_y = y; }
48 52
void (gunner_set_angle)(gunner_t *p, double angle      ){
49 53
    sprite_set_angle(p->dude  , angle);
50 54
    sprite_set_angle(p->weapon, angle);
......
59 63
}
60 64
double  (gunner_get_x)              (const gunner_t *p){ return p->x; }
61 65
double  (gunner_get_y)              (const gunner_t *p){ return p->y; }
66
double  (gunner_get_spawn_x)        (const gunner_t *p){ return p->spawn_x; }
67
double  (gunner_get_spawn_y)        (const gunner_t *p){ return p->spawn_y; }
62 68
double  (gunner_get_angle)          (const gunner_t *p){ return sprite_get_angle(p->dude); }
63 69
int     (gunner_get_health)         (const gunner_t *p){ return p->health; }
64 70
int     (gunner_get_curr_health)    (const gunner_t *p){ return p->current_health; }
......
107 113
    ret-> y =  y;
108 114
    ret->vx = vx;
109 115
    ret->vy = vy;
110
    ret->damage = 1;
116
    ret->damage = 10;
111 117
    ret->b = sprite_ctor(b);
112 118
    if(ret->b == NULL){
113 119
        bullet_dtor(ret);
proj/src/proj.c
140 140
        ent_set_scale(DEFAULT_SCALE);
141 141

  
142 142
        gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n");
143
        gunner_set_spawn(shooter1, 75, 75);
143 144
        gunner_set_pos(shooter1, 75, 75);
144 145

  
145 146
        gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_nothing);
147
        gunner_set_spawn(shooter2, 975, 75);
146 148
        gunner_set_pos(shooter2, 775, 75);
147 149

  
148 150
        //bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0);
......
184 186
                                if (no_interrupts % refresh_count_value == 0) {
185 187
                                    update_movement(map1, shooter1);
186 188
                                    //bullet_update_movement(bullet);
189

  
190
                                    if (no_interrupts % 180 == 0) gunner_set_pos(shooter2, 775, 75);
191

  
187 192
                                    update_game_state(map1, shooter2, bullet_list);
188 193

  
189 194
                                    if(map_collides_gunner(map1, shooter1)){
......
194 199
                                        printf("Bullet Collide with Shooter\n");
195 200
                                        gunner_set_curr_health(shooter1, gunner_get_curr_health(shooter1) - bullet_get_damage(bullet));
196 201
                                    }*/
197

  
198 202
                                    update_scale();
199 203

  
200 204
                                    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
proj/src/proj_func.c
93 93
            list_node_t *aux = list_node_next(it);
94 94
            bullet = (bullet_t*)list_erase(bullet_list, it);
95 95
            gunner_set_curr_health(shooter, gunner_get_curr_health(shooter) - bullet_get_damage(bullet));
96
            if (gunner_get_curr_health(shooter) <= 0) {
97
                gunner_set_curr_health(shooter, gunner_get_health(shooter));
98
                gunner_set_pos(shooter, gunner_get_spawn_x(shooter), gunner_get_spawn_y(shooter));
99
            }
100

  
96 101
            free(bullet);
97 102
            it = aux;
98 103
            continue;

Also available in: Unified diff