mur * trouver_mur(coordonnee * depart, double d_x, double d_y, carte * map, int boolean) { int i, j; coordonnee * point; double val_distance_point, val_portion_texture; point = coordonnee_cp(depart); while(limite(point)){ i = coordonnee_get_x(point) / 100; j = coordonnee_get_y(point) / 100; if(carte_get_info(map,i,j) != 0){ val_distance_point = distance_point(depart, point); val_portion_texture = gen_portion_texture(point, boolean); coordonnee_free(point); return mur_new(carte_get_info(map,i,j), val_distance_point, val_portion_texture); } if(carte_get_info(map,i-1,j) != 0){ val_distance_point = distance_point(depart, point); val_portion_texture = gen_portion_texture(point, boolean); coordonnee_free(point); return mur_new(carte_get_info(map,i-1,j), val_distance_point, val_portion_texture); } if(carte_get_info(map,i,j-1) != 0){ val_distance_point = distance_point(depart, point); val_portion_texture = gen_portion_texture(point, boolean); coordonnee_free(point); return mur_new(carte_get_info(map,i,j-1), val_distance_point, val_portion_texture); } if(carte_get_info(map,i-1,j-1) != 0){ val_distance_point = distance_point(depart, point); val_portion_texture = gen_portion_texture(point, boolean); coordonnee_free(point); return mur_new(carte_get_info(map,i-1,j-1), val_distance_point, val_portion_texture);} //on avance à la prochaine intersection coordonnee_set_x(point, coordonnee_get_x(point) + d_x); coordonnee_set_y(point, coordonnee_get_y(point) + d_y); } coordonnee_set_x(point, MAX_X); coordonnee_set_y(point, MAX_Y); val_distance_point = distance_point(depart, point); coordonnee_free(point); return mur_new(-1, val_distance_point, 0); }
/*Reconstruit la liste des discontinuite depuis 0*/ void research_discontinuity(data_jeu* d) { list_ball* l=&(d->file_balls); node_ball* it2=begin_list_ball(*l); clear_list_discontinuity(&(d->discontinuity)); it2=begin_list_ball(*l); while(it2 && it2->next) { if(distance_point(it2->val.point_courant,it2->next->val.point_courant)>=(32*32*COEFF_MAGIQUE)) { append_list_discontinuity(&(d->discontinuity),it2); append_list_discontinuity(&(d->discontinuity),it2->next); } it2=it2->next; } }
void merge_discontinuity(data_jeu* tmp) { list_discontinuity* l=0; node_discontinuity* it=0; list_ball* file_balls=0 ;int* adding_ball=0 ; /* SDL_mutex* mutex =tmp->mutex; SDL_LockMutex(mutex);*/ l=&(tmp->discontinuity); it=begin_list_discontinuity(*l); file_balls=&(tmp->file_balls);adding_ball=&(tmp->adding_ball); if(size_list_discontinuity(*l)>1) { while(it && it->next) { if(it->next && (distance_point(it->next->val->val.point_courant,it->val->val.point_courant)<32*32*COEFF_MAGIQUE)&& it->next->val->val.nb!=it->val->val.nb) { node_discontinuity* next=it->next->next; node_ball* it_ball=it->val; /*On retire les discontinuites*/ remove_node_list_discontinuity(l,it->next); remove_node_list_discontinuity(l,it); if(it_ball->val.current_movement==backward) { /*On dit a la tete de cortege de s'arrete */ node_ball* it2_ball=end_list_ball(*file_balls); do { it_ball->val.current_movement=stay_still; it_ball=it_ball->previous; } while(it_ball!=file_balls->head && !(find_list_discontinuity(*l,it_ball))); /*On dit a l'arriere du cortege de demarer */ do { it2_ball->val.current_movement=forward; it2_ball=it2_ball->previous; } while( (!find_list_discontinuity(*l,it2_ball) )&& it2_ball!=file_balls->head); print2_list_discontinuity(l); *adding_ball=1; tmp->throw_projectile=1; } else if(it_ball->val.current_movement==stay_still) { /*On demande au bout de cortege qui s'était arrete avant de repartir*/ node_ball* it2_ball=end_list_ball(*file_balls); do { it2_ball->val.current_movement=forward; it2_ball=it2_ball->previous; } while( (!find_list_discontinuity(*l,it2_ball->next)) && it2_ball!=file_balls->head); } else { printf("SOUCIS \n"); } it=next; } else { it=it->next; } } } /* SDL_UnlockMutex(mutex);*/ }