// remove a single fruit from the game by it's position void kill_fruit(FRUITS *fruits, int posy, int posx) { FRUIT *fruit; // check if a fruit is on the given position if((fruit = fruit_is_on(fruits, posy, posx)) != NULL) { // remove the fruit kill_fruit_by_ptr(fruits, fruit); } }
// calls the effect of the fruit int check_fruit_collision_handler(GAME* game, int cury, int curx) { // the the fruit by the given position FRUIT *fruit = fruit_is_on(&game->fruits, cury, curx); // is one on this position? if(fruit != NULL) { // execute the effect of the fruit fruit->effect(game); WINDOW *win = newwin(1, 1, cury, curx); wprintw(win, " "); wrefresh(win); delwin(win); // remove the fruit from the game kill_fruit_by_ptr(&game->fruits, fruit); } return 1; }