/* As is usual, main() just sets up a few things, then pass over * control to a different controlling function */ int main(void) { int retval; struct env board; struct creature pac; struct creature ghost[NUM_GHOSTS]; printf("This is %s, version %s by Stig Brautaset\n", PACKAGE_NAME, PACKAGE_VERSION); printf("Report bugs to %s\n\n", PACKAGE_BUGREPORT); if (!read_layout(&board)) return EXIT_FAILURE; /* set up our gui things */ if (!init_gui(board.rows, board.cols)) return EXIT_FAILURE; /* initialise the random number generator */ srand(time(NULL)); /* main game loop */ retval = main_game_loop(&board, &pac, ghost, NUM_GHOSTS); d2_free_location_proper(board.pos, board.rows, board.cols); return EXIT_SUCCESS; }
// set need_to_initialise to zero if loading from disk (in which case the world has been initialised by the load function) // * currently need_to_initialise should always be 0 void run_game(void) { init_main_loop(); main_game_loop(); // ends when game over (or user quit) game.watching = WATCH_OFF; // bcp_state.bcp_mode = BCP_MODE_EMPTY; init_bcode_panel(); if (game.type == GAME_TYPE_MISSION) { w.players = 1; // this affects the template panel (prevents opening the old player 1 templates in the mission select screen) if (game.game_over_status == GAME_END_MISSION_COMPLETE) { story_mission_defeated(); } } close_all_panels(); deallocate_world(); // must be called at end of game (it frees memory allocated by init_main_loop()) reset_music(1, 0, rand()); }
void do_play_game() { while (!abort_engine) { main_game_loop(); if (load_new_game) { RunAGSGame (NULL, load_new_game, 0); load_new_game = 0; } } }
int main(int argc, char *argv[]) { nstate *state = my_malloc(sizeof(nstate)); init_game(state); main_game_loop(state); write_hiscore(state); GrClose(); return 0; }