Project

General

Profile

Revision 238

changed a small thing but not yet working, go telmo!

View differences:

proj/include/proj_func.h
17 17
/**
18 18
 * @brief Updates movement variables.
19 19
 */
20
void update_movement(const map_t *map, gunner_t *p, gunner_t *p2);
20
void update_movement(const map_t *map, list_t *shooter_list);
21 21

  
22 22
typedef struct keys {
23 23
    uint8_t w_pressed       : 1;
proj/src/proj.c
231 231
                            #ifdef TELMO
232 232
                            if (i == 0) {
233 233
                                if (no_interrupts % refresh_count_value == 0) {
234
                                    update_movement(map1, shooter1, shooter2);
234
                                    update_movement(map1, shooter_list);
235 235
                                    //bullet_update_movement(bullet);
236 236

  
237 237
                                    if (no_interrupts % 180 == 0) gunner_set_pos(shooter2, 775, 75);
......
242 242
                                        printf("COLLIDING\n");
243 243
                                    }
244 244

  
245
                                    /*if (gunner_collides_bullet(shooter1, bullet)) {
246
                                        printf("Bullet Collide with Shooter\n");
247
                                        gunner_set_curr_health(shooter1, gunner_get_curr_health(shooter1) - bullet_get_damage(bullet));
248
                                    }*/
249 245
                                    update_scale();
250 246

  
251 247
                                    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
......
297 293
    }
298 294

  
299 295
    #ifdef TELMO
300
        //gunner_dtor(shooter1); shooter1 = NULL;
301
        //gunner_dtor(shooter2); shooter2 = NULL;
302

  
303 296
        while(list_size(shooter_list) > 0){
304 297
            gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
305 298
            gunner_dtor(p);
proj/src/proj_func.c
51 51
    hor_mov = key_presses.d_pressed - key_presses.a_pressed;
52 52
}
53 53

  
54
void update_movement(const map_t *map, gunner_t *p, gunner_t *p2) {
55
    double x = gunner_get_x(p);
56
    double y = gunner_get_y(p);
57
    gunner_set_pos(p, x + SHOOTER_SPEED * hor_mov, y);
58
    if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
59
        gunner_set_pos(p, x, y);
54
void update_movement(const map_t *map, list_t *shooter_list){
55
    list_node_t *it1 = list_begin(shooter_list);
56
    while(it1 != list_end(shooter_list)){
57
        double x = gunner_get_x(p);
58
        double y = gunner_get_y(p);
59
        gunner_set_pos(p, x + SHOOTER_SPEED * hor_mov, y);
60
        if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
61
            gunner_set_pos(p, x, y);
62
        }
63
        x = gunner_get_x(p);
64
        gunner_set_pos(p, x, y + SHOOTER_SPEED * ver_mov);
65
        if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
66
            gunner_set_pos(p, x, y);
67
        }
60 68
    }
61
    x = gunner_get_x(p);
62
    gunner_set_pos(p, x, y + SHOOTER_SPEED * ver_mov);
63
    if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
64
        gunner_set_pos(p, x, y);
65
    }
66 69
}
67 70

  
68 71
void (shoot_bullet)(const gunner_t *shooter, list_t *bullet_list, const basic_sprite_t *bsp_bullet) {

Also available in: Unified diff