Project

General

Profile

Revision 341

more changes in ent.h, ent.c

View differences:

ent.c
381 381
    double distance = sqrt(dx*dx + dy*dy);
382 382
    return distance <= shooter_radius+bullet_radius;
383 383
}
384
void (get_random_spawn)(const map_t *map, gunner_t *p, list_t *l) {
385
    uint16_t w = map_get_width(map), h = map_get_height(map);
386
    double x, y;
387

  
388
    while(true){
389
        x = rand() % w;
390
        y = rand() % h;
391
        gunner_set_pos(p, x, y);
392
        if(map_collides_gunner(map, p)) continue;
393
        int collides = false;
394
        list_node_t *it = list_begin(l);
395
        while(it != list_end(l)){
396
            if(gunner_collides_gunner(p, *list_node_val(it))){
397
                collides = true;
398
                break;
399
            }
400
            it = list_node_next(it);
401
        }
402
        if(!collides) return;
403
    }
404
}

Also available in: Unified diff