2 Star 1 Fork 1

hansen0730 / Typing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
screen.c 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
Hansen Fang 提交于 2014-07-19 18:23 . [Init] Setup prj
#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;
}
C
1
https://gitee.com/hansen0730/Typing.git
git@gitee.com:hansen0730/Typing.git
hansen0730
Typing
Typing
master

搜索帮助