void draw_creatures(struct creature* critters){ struct creature * cr = critters; while(NULL != cr){ draw_creature(cr); cr = cr->next; } }
static int main_game_loop(struct env *board, struct creature *pac, struct creature *ghost, int cnt) { unsigned long time_to_sleep; enum dir_t direction; int i, won = 0; draw_board(board); box_print(0, 0, "Welcome. Hit any key to start :)"); update_view(); blocking_input(); do { /* set up and place the players (ghosts etc) */ if (!init_players(board, pac, ghost, cnt)) return 0; /* blank out screen, ready for action */ reset_view(); draw_board(board); time_to_sleep = INITIAL_DELAY; for (;;) { /* check for user input */ direction = get_user_input(); if (direction == QUIT) break; move_pac(board, pac, direction); draw_creature(board, pac); erase_tail(board, pac); /* Move and draw N ghosts. */ for (i=0; i<cnt; i++) { ghost_move(board, &(ghost[i]), i); draw_creature(board, &(ghost[i])); erase_tail(board, &(ghost[i])); } /* Up the score if we got any cherries, * then print the new (or old) score. */ pick_up_cherries(board, pac); print_stat(board); /* update the whole screen */ update_view(); /* Check if there's any more cherries to * pick, otherwise the game is won. */ won = game_won(board); if (won) break; if (pac_caught(pac, ghost, cnt)) { down_lives(board); break; } /* * Sleep for a short while. This function is not * ANSI/ISO-C. */ usleep(time_to_sleep); if (time_to_sleep > MIN_DELAY) time_to_sleep -= DEC_DELAY; } } while (direction != QUIT && !won && lives_left(board) > 0 && play_again()); finish(won, lives_left(board)); return 1; }