void menuSelect() { setvbuf(stdout, NULL, _IONBF, 0); while (1) { printf("> "); char command[32]; fgets(command, 32*sizeof(char), stdin); command[strcspn(command, "\n")] = 0; if (command[0] == 'q') { printf("Goodbye.\n"); break; } else if (command[0] == '?') { printf("Commands:\n"); printf("\t?: Print this command list\n"); printf("\tq: Quit\n"); printf("\tBackground: Add another background picture\n"); printf("\tTarget: Add another target image\n"); printf("\tGenerate: Create a puzzle\n"); } else if (strcmp(command, "Background") == 0) { addBackground(); } else if (strcmp(command, "Target") == 0) { addTarget(); } else if (strcmp(command, "Generate") == 0) { generatePuzzle(); } } }
void StarPuzzle::initPuzzle(PuzzleLevel level) { for (int i = 0; i < 10; i++) { //CCLog("generatePuzzle times %d", i+1); clearPuzzle(); generatePuzzle(level); if (evaluateMaxScore() >= 2000) break; } createStars(); hideAllStars(); }
Grid::Grid(string mode) { if (mode == "easy") { generatePuzzle(40); } else if (mode == "medium") { generatePuzzle(25); } else if (mode == "hard") { generatePuzzle(10); } else { generatePuzzle(40); } }
static void menu_select_loop() { for(;;) { printf("=>"); char command[128]; getstr(command,128); if(command[0]=='q') break; if(command[0]=='?') { printf("Commands:\n"); printf("\t? : print this command list\n"); printf("\tq : quit\n"); printf("\tBackground: add another backgroud picture\n"); printf("\tTarget: add another target image\n"); printf("\tGenerate: create a puzzle\n"); } if(0==strcmp(command, "Background")) addBackgroud(); else if(0==strcmp(command, "Target")) addTarget(); else if(0==strcmp(command, "Generate")) generatePuzzle(); } }