/**************************************************************************** Apply desired action depending on user's request (clicked button). ****************************************************************************/ void option_dialog::apply_option(int response) { switch (response) { case RESPONSE_APPLY: apply_options(); break; case RESPONSE_CANCEL: ::dialog_list.remove(curr_options); close(); break; case RESPONSE_OK: apply_options(); ::dialog_list.remove(curr_options); close(); break; case RESPONSE_SAVE: desired_settable_options_update(); options_save(); break; case RESPONSE_RESET: full_reset(); break; case RESPONSE_REFRESH: full_refresh(); break; } }
void roguelike() { enum { KEY_ESC = 27, KEY_ENTER = '\r', KEY_BACKSPACE = 8, CTRL_S = 19, CTRL_P = 16, CTRL_Q = 17, CTRL_B = 2, KEY_UP = 72, KEY_DOWN = 80, KEY_LEFT = 75, KEY_RIGHT = 77}; char screenmap[info.screenheight][info.screenwidth+1]; //y then x memset(screenmap, ' ', (info.screenwidth+1)*info.screenheight); struct creature * critters = create_creature("playa", '@', LIGHTGRAY, 16+((info.screenwidth-16)/2), info.screenheight/2); struct creature * head = critters; head->next = create_creature("monsu", 'M', RED, 16+20, 20); /* store player for convenience*/ struct creature * player = critters; //construct terrain // for (int i = 0; i <2; i++){ // terrain[i].character = symbols[i][0]; // terrain[i].color = symbols[i][1]; // } for (int i = 3; i <256; i++){ // zero unused values // terrain[i].name="undefined"; terrain[i].character = 0; terrain[i].color = 0; } int val; // getch value clrscr(); char * title[] = {"Roguelike", "Press Any Key"}; for (int i=0; i!=2; i++){ gotoxy((info.screenwidth-(strchr(title[i], '\0')-title[i]))/2, -3+i+info.screenheight/2); printf("%s", title[i]); } getch(); clrscr(); for (int i = 0; i < info.screenheight-1; i++){ screenmap[i][15] = '|'; screenmap[i][0] = '*'; screenmap[i][info.screenwidth-1] = '*'; screenmap[i][info.screenwidth]='\0'; } for (int i = 0; i < info.screenwidth; i++){ screenmap[0][i] = '*'; screenmap[info.screenheight-2][i] = '*'; } //let's make a lawn for (int y=1; y < info.screenheight-2; y++) { for (int x=16; x < info.screenwidth-1; x++) { screenmap[y][x] = (90 < rand() % 100) ? WATER : GRASS; } } // a wall.... // for (int x=20; x<30;x++){ screenmap[5][x] = WALL; screenmap[15][x] = WALL; } for (int y=5; y<15;y++){ screenmap[y][20] = WALL; screenmap[y][30] = WALL; } textcolor(WHITE); full_refresh(&screenmap[0][0], terrain); draw_creatures(head); gotoxy(0,0); _setcursortype(_NOCURSOR); _setcursortype(0); while((val=getch())!=CTRL_Q) { erase_creatures(head, &screenmap[0][0], terrain); player = handle_input(val, player, (char *)screenmap); head = update_creature_position(head, player->name, player->x, player->y); draw_creatures(head); textcolor(WHITE); putchxy(2, 2, ':'); printf("Test"); _setcursortype(_NOCURSOR); _setcursortype(0); } _setcursortype(_NORMALCURSOR); textcolor(YELLOW); }