void loop_bullets(WINDOW * win_game, struct bulletlist * list_bu, struct player * pl, struct obstaclelist * list_ob) { struct bullet * bu_cur; /* Debugging */ int j; char * string; string = malloc(4 + (size_t) get_digits((unsigned int) list_bu->count) + sizeof('\0')); sprintf(string, "BC: %d", list_bu->count); for (j = 0; j < (int) strlen(string); j++) { mvwaddch(win_game, 0, 40 + j, ' '); } mvwprintw(win_game, 0, 40, "BC: %d", list_bu->count); wrefresh(win_game); free(string); if (list_bu->count > 0) { for (bu_cur = list_bu->head; bu_cur != NULL; bu_cur = bu_cur->next) { if (bu_cur->x_pos > FIELDMAXX) { assert(destroy_bullet(win_game, list_bu, bu_cur) == EXIT_SUCCESS); } else { struct obstacle * ob_cur; move_bullet(win_game, bu_cur); for (ob_cur = list_ob->head; ob_cur != NULL; ob_cur = ob_cur->next) { if (bu_cur->x_pos == ob_cur->x_pos && bu_cur->y_pos == ob_cur->y_pos) { int y = bu_cur->y_pos; int x = bu_cur->x_pos; /* Debug */ fprintf(debuglog, "loop_bullets()\n\tBullet %p collided with obstacle %p!\n\tCollision x_pos: %d\n\tCollision y_pos: %d\n", (void *) bu_cur, (void *) ob_cur, ob_cur->x_pos, ob_cur->y_pos); fflush(debuglog); assert(destroy_bullet(win_game, list_bu, bu_cur) == EXIT_SUCCESS); assert(destroy_obstacle(win_game, list_ob, ob_cur) == EXIT_SUCCESS); set_char_attr(win_game, y, x, A_BOLD, YELLOW_BLACK, '*'); pl->score += OBSTACLESCORE; } } } } } }