代码拉取完成,页面将自动刷新
#include <ncurses.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "doge.h"
int mr,mc,opt = 0;
time_t time_ctr;
extern bool typing;
// Sets up the screen, and prepares the game.
// Sets ip color pairs and prepares the game for using user input.
// Displays pregame splash.
void init_menu(){
srand(time(NULL));
initscr();
getmaxyx(stdscr,mr,mc);
start_color();
use_default_colors();
init_pair(1,COLOR_YELLOW,-1);
raw();
keypad(stdscr,TRUE);
curs_set(0);
noecho();
//printdoge();
attron(COLOR_PAIR(1));
refresh();
attroff(COLOR_PAIR(1));
show_menu();
}
void show_menu(){
clear();
//mvprintdoge(0,0);
//attron(COLOR_PAIR(1) | A_BOLD);
//attroff(A_BOLD);
if (opt == 0){ attron(A_STANDOUT); }
mvprintw(3,4,"Start");
if (opt == 0){ attroff(A_STANDOUT); }
if (opt == 1){ attron(A_STANDOUT); }
mvprintw(5,4,"Exit");
if (opt == 1){ attroff(A_STANDOUT); }
refresh();
switch(getch()){
case KEY_RESIZE:
endwin();
getmaxyx(stdscr,mr,mc);
refresh();
show_menu();
break;
case KEY_UP:
if (opt > 0){
--opt;
}
break;
case KEY_DOWN:
if (opt < 1){
++opt;
}
break;
case 10: // ENTER
switch(opt){
case 0:
start_game();
return;
break;
case 1:
endwin();
exit(0);
break;
}
break;
}
show_menu();
}
// Prints the time (started from a pthread).
void * print_time(void *id)
{
int r,c; // Row and column when this is called.
while (1)
{
if(typing)
{
getyx(stdscr,r,c);
time(&time_ctr);
show_time();
move(r,c);
refresh();
}
sleep(1);
}
return NULL;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。