Revision 302
working on zombies
proj_func.c | ||
---|---|---|
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
void (update_game_state)(const map_t *map, list_t *shooter_list, list_t *bullet_list) { |
95 |
|
|
95 |
/// BULLETS |
|
96 | 96 |
bullet_update_movement_list(bullet_list); |
97 |
|
|
98 | 97 |
list_node_t *bullet_it = list_begin(bullet_list); |
99 | 98 |
while (bullet_it != list_end(bullet_list)) { |
100 | 99 |
/// Collision with walls |
... | ... | |
112 | 111 |
int deleted_bullet = false; |
113 | 112 |
while(shooter_it != list_end(shooter_list)){ |
114 | 113 |
gunner_t *shooter = *(gunner_t**)list_node_val(shooter_it); |
115 |
if(gunner_collides_bullet(shooter, bullet)) { |
|
114 |
if(gunner_collides_bullet(shooter, bullet) && |
|
115 |
gunner_get_team(shooter) != gunner_get_team(bullet_get_shooter(bullet))) { |
|
116 | 116 |
list_node_t *aux = list_node_next(bullet_it); |
117 | 117 |
/// Change health |
118 | 118 |
gunner_set_curr_health(shooter, gunner_get_curr_health(shooter) - bullet_get_damage(bullet)); |
... | ... | |
130 | 130 |
/// Advance iterator if necessary |
131 | 131 |
bullet_it = list_node_next(bullet_it); |
132 | 132 |
} |
133 |
/// MEELEE |
|
134 |
list_node_t *it1 = list_begin(shooter_list); |
|
135 |
while(it1 != list_end(shooter_list)){ |
|
136 |
gunner_t *s1 = *list_node_val(it1); |
|
137 |
if(gunner_get_type(s1) != gunner_meelee){ it1 = list_node_next(it1); continue; } |
|
138 |
list_node_t *it2 = list_begin(shooter_list); |
|
139 |
while(it2 != list_end(shooter_list)){ |
|
140 |
gunner_t *s2 = *list_node_val(it2); |
|
141 |
if(s1 != s2 && gunner_distance(s1, s2) < MEELEE_RANGE) |
|
142 |
gunner_set_curr_health(s2, gunner_get_curr_health(s2) - MEELEE_DAMAGE); |
|
143 |
if(gunner_get_curr_health(s2) <= 0){ |
|
144 |
list_node_t *aux = list_node_next(it2); |
|
145 |
gunner_dtor(list_erase(shooter_list, it2)); |
|
146 |
it2 = aux; |
|
147 |
}else it2 = list_node_next(it2); |
|
148 |
} |
|
149 |
it1 = list_node_next(it1); |
|
150 |
} |
|
133 | 151 |
} |
134 | 152 |
|
135 | 153 |
void (get_random_spawn)(const map_t *map, gunner_t *p) { |
Also available in: Unified diff