void create_new_ghost() { GHOST ghost; init_ghost(&ghost); while(1) { move_ghost(&ghost); sleep(ghost_sleep); } }
void create_new_ghost() { GHOST ghost; int dx, dy; init_ghost(&ghost); choose_random_direction(&dx, &dy); while (1) { sleep(10); while (move_ghost(&ghost, dx, dy) == FALSE) { choose_random_direction(&dx, &dy); } } }
void play(SDL_Surface* screen) { int x; int y; x = 10; while (g_playloop == 1) { y = 23; SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 5, 5, 5)); fontmap_printf(x, y, screen, "304-PACMAN <PAYET-S> + 1UP: 0 + " "SCORE: %03d + TIME: %d", g_score, g_time); y += FONTMAP_SIZE * 2; fontmap_print(x, y, screen, g_prompt.c_str()); y += FONTMAP_SIZE * 2; handle_event(screen, y); y += FONTMAP_SIZE * 2; for (auto line : g_map) { fontmap_print(x, y, screen, line.c_str()); y += FONTMAP_SIZE; } if (g_choose_file == 1) g_prompt = "$> Choose a map."; else if (g_count <= (g_score / 10)) g_prompt = "$> Congratulation!"; else if (g_pause == 0) { g_prompt = "$> GO!"; g_time += 1; if ((g_time % 100) == 0) { move_player(); move_ghost(); } } else if (g_pause == 1) { g_prompt = "$> Game is paused."; } SDL_Flip(screen); } }