Example #1
0
/*
 * setup:
 *	Set up the strings on the screen.
 */
void
setup()
{
	register char		**sp;
	static struct stat	sbuf;

	noecho();
	crmode();

	mvaddstr(PROMPTY, PROMPTX, "Guess:");
	mvaddstr(GUESSY, GUESSX, "Guessed:");
	mvaddstr(NUMBERY, NUMBERX, "Word #:");
	mvaddstr(AVGY, AVGX, "Current Average:");
	mvaddstr(AVGY + 1, AVGX, "Overall Average:");
	mvaddstr(KNOWNY, KNOWNX, "Word: ");

	for (sp = Noose_pict; *sp != NULL; sp++) {
		move(sp - Noose_pict, 0);
		addstr(*sp);
	}

	srandom(time(NULL) + getpid());
	if ((Dict = fopen(DICT, "r")) == NULL) {
		perror(DICT);
		endwin();
		exit(1);
	}
	fstat(fileno(Dict), &sbuf);
	Dict_size = sbuf.st_size;
}
Example #2
0
void set_up()
/*
 * init structure and other stuff
 * */
{
	void ball_move(int);

	the_ball.y_pos = Y_INIT;
	the_ball.x_pos = X_INIT;
	the_ball.y_ttg = the_ball.y_ttm = Y_TTM;
	the_ball.x_ttg = the_ball.x_ttm = X_TTM;
	the_ball.y_dir = 1;
	the_ball.x_dir = 1;
	the_ball.symbol = DFL_SYMBOL;

	initscr();
	noecho();
	crmode();

	signal( SIGINT, SIG_IGN);	/* ignore the ^C signal */
	mvaddch( the_ball.y_pos, the_ball.x_pos, the_ball.symbol);
	refresh();

	signal( SIGALRM, ball_move);
	set_ticker( 1000/ TICKS_PER_SEC);
		/* send millisecs per tick */
}
Example #3
0
main()
{
    void on_alarm(int);     // handler for alarm
    void on_input(int);     // handler for keybd
    void enable_kbd_signals();

    initscr();
    crmode();
    noecho();
    clear();

    signal(SIGIO, on_input);        // install the handler
    enable_kbd_signals();
    signal(SIGALRM, on_alarm);
    set_ticker(delay);              // start ticking

    move(row, col);
    addstr(MESSAGE);

    while (1)
    {
        if (done == 1) break;
        pause();
    }
    endwin();
}
Example #4
0
int main()
{
	welcom();
	tty_mode(0);//储存TTY的模式
	initscr();
	crmode();
	noecho();
	clear();
	box(stdscr,'|','-');
	mvaddch(pos_x,pos_y,BALL);
	bpos_x=LINES-4;
	bpos_y=4;
	mvaddstr(bpos_x,bpos_y,BAN);
	move(LINES-1,COLS-1);			//移动光标到右下角
	refresh();
	signal(SIGALRM,jmove);
	delay=50;	//200ms=0.2s
	if(set_ticker(delay) == -1)
		perror("set_ticker");
	else
		while(1)
		{
			ndelay = 0;
			c=getch();
			if(c=='Q') break;
			if(c=='f' && delay > 2) ndelay = delay/2;
			if(c=='s') ndelay = delay*2;
			if(c==' ') bdir_y=-bdir_y;
			if(ndelay > 0) set_ticker (delay = ndelay);
			//重置定时器
		}
}
int main() {
    int ndelay;
    int c;
    pthread_t msg_thread;
    void * moving_msg();

    initscr();
    crmode();
    noecho();
    clear();

    row = 10;
    col = 0;
    dir = 1;
    delay = 200;
    if(pthread_create(&msg_thread, NULL, moving_msg, MESSAGE)) {
        fprintf(stderr, "error creating thread");
        endwin();
        exit(0);
    }

    while(1) {
         ndelay = 0;
         c = getch();
         if (c == 'Q') break;
         if (c == ' ') dir = -dir;
         if (c == 'f' && delay > 2) ndelay = delay/2;
         if (c == 's') ndelay = delay * 2;
         if (ndelay > 0)
             delay = ndelay;
    }
    pthread_cancel(msg_thread);
    endwin();
}
Example #6
0
void set_up()
{
    theball.y_pos = Y_INIT;
    theball.x_pos = X_INIT;

    theball.y_ttg = theball.y_ttm = Y_TTM;
    theball.x_ttg = theball.x_ttm = X_TTM;

    theball.y_dir = 1;
    theball.x_dir = 1;

    theball.symbol = DEL_SYMBOL;

    thebaffles.length = BAFFLE_LEN;
    thebaffles.x_baffle_pos = RIGHT_EDGE - (RIGHT_EDGE - LEFT_EDGE) / 2 - BAFFLE_LEN / 2;
    thebaffles.y_baffle_pos = BOTTOM_ROW - (BOTTOM_ROW - TOP_ROW) / 2 - BAFFLE_LEN / 2;

    initscr();
    noecho();
    crmode();

    signal(SIGINT, SIG_IGN);

    draw_baffles();

    mvaddch(theball.y_pos, theball.x_pos, theball.symbol);
    refresh();

    signal(SIGALRM, refresh_draw);

    set_ticker(1000 / TICKS_PER_SEC);
}
Example #7
0
/*
 * flush_in:
 *	Flush all pending input.
 */
flush_in()
{
# ifdef TIOCFLUSH
	ioctl(fileno(stdin), TIOCFLUSH, NULL);
# else TIOCFLUSH
	crmode();
# endif TIOCFLUSH
}
Example #8
0
void setup()
{
	/* set up curses */
	initscr();
	crmode();
	noecho();
	clear();
}
Example #9
0
/*
 * Set up curses, catch the appropriate signals,
 * and build the various windows.
 */
int
init_display (void)
{
#ifdef HAVE_SIGACTION
  struct sigaction siga;
#else
# ifdef HAVE_SIGVEC
  struct sigvec sigv;
# endif
#endif

  if (initscr () == NULL)
    error (EXIT_FAILURE, 0, "Terminal type unset or lacking necessary features.");

#ifdef HAVE_SIGACTION
  sigaction (SIGTSTP, (struct sigaction *) 0, &siga);
  sigaddset (&siga.sa_mask, SIGALRM);
  sigaction (SIGTSTP, &siga, (struct sigaction *) 0);
#else /* !HAVE_SIGACTION */
# ifdef HAVE_SIGVEC
  sigvec (SIGTSTP, (struct sigvec *) 0, &sigv);
  sigv.sv_mask |= sigmask (SIGALRM);
  sigvec (SIGTSTP, &sigv, (struct sigvec *) 0);
# endif	/* HAVE_SIGVEC */
#endif /* HAVE_SIGACTION */

  curses_initialized = 1;
  clear ();
  refresh ();
  noecho ();
  crmode ();

  signal (SIGINT, sig_sent);
  signal (SIGPIPE, sig_sent);

  /* curses takes care of ^Z */
  my_win.x_nlines = LINES / 2;
  my_win.x_ncols = COLS;
  my_win.x_win = newwin (my_win.x_nlines, my_win.x_ncols, 0, 0);
  scrollok (my_win.x_win, FALSE);
  wclear (my_win.x_win);

  his_win.x_nlines = LINES / 2 - 1;
  his_win.x_ncols = COLS;
  his_win.x_win = newwin (his_win.x_nlines, his_win.x_ncols,
			  my_win.x_nlines + 1, 0);
  scrollok (his_win.x_win, FALSE);
  wclear (his_win.x_win);

  line_win = newwin (1, COLS, my_win.x_nlines, 0);
  box (line_win, '-', '-');
  wrefresh (line_win);
  /* let them know we are working on it */
  current_state = "No connection yet";

  return 0;
}
Example #10
0
void init_disp()
{
    initscr();
    clear();
    crmode();
    noecho();
    nonl();
    draw_field();
}
Example #11
0
void
cont_catcher()
{
    sigset(SIGCONT,cont_catcher);
    savetty();
    crmode();
    raw();
    noecho();
    nonl();
}
 ConsoleDisplayT() {
   // Menu
   initscr();
   crmode();
   keypad(stdscr, TRUE);
   noecho();
   clear();
   refresh();
   timeout(10); // makes getch() non-blocking
 }
/*
 * setup:
 *	Get starting setup for all games
 */
setup()
{
    void  auto_save(), quit(), endit(), tstp();
#ifdef CHECKTIME
    int  checkout();
#endif

    /*
     * make sure that large terminals don't overflow the bounds
     * of the program
     */
    if (LINES > MAXLINES)
	LINES = MAXLINES;
    if (COLS > MAXCOLS)
	COLS = MAXCOLS;

#ifdef SIGHUP
    signal(SIGHUP, auto_save);
#endif
#ifndef DUMP
    signal(SIGILL, auto_save);
#ifdef SIGTRAP
    signal(SIGTRAP, auto_save);
#endif
#ifdef SIGIOT
    signal(SIGIOT, auto_save);
#endif
#ifdef SIGEMT
    signal(SIGEMT, auto_save);
#endif
    signal(SIGFPE, auto_save);
#ifdef SIGBUS
    signal(SIGBUS, auto_save);
#endif
    signal(SIGSEGV, auto_save);
#ifdef SIGSYS
    signal(SIGSYS, auto_save);
#endif
    signal(SIGTERM, auto_save);
#endif

    signal(SIGINT, quit);
#ifndef DUMP
#ifdef SIGQUIT
    signal(SIGQUIT, endit);
#endif
#endif
#ifdef CHECKTIME
    signal(SIGALRM, checkout);
    alarm(CHECKTIME * 60);
    num_checks = 0;
#endif
    crmode();				/* Cbreak mode */
    noecho();				/* Echo off */
}
Example #14
0
int main()
{
    //初始化 curses
    initscr();
    crmode();  /*中断模式*/
    noecho();  /*关闭回显*/
     
    move(6,28);
    attron(A_BOLD);
    addstr("Welcome to the BallGame!");
    move(8,20);
    attroff(A_BOLD);
    addstr("Help:");
    move(9,23);
    addstr("'N':Start a new game.");
    move(10,23);
    addstr("'Q':Quit game.");
    move(11,23);
    addstr("'KEY_LEFT' :Control baffle left  shift.");
    move(12,23);
    addstr("'KEY_RIGHT':Control baffle right shift.");
    move(13,23);
    addstr("'KEY_UP'   :Control of the ball speed.");
    move(14,23);
    addstr("'KEY_DOWN' :Control of the ball reducer.");
    int flag=1;
    char choice;
    move(16,24);
    addstr("Please choose your choice!(n/q):");
    refresh();
    choice=getch();
    while(flag){
        if(choice=='q'||choice=='Q'||choice=='n'||choice=='N')
             flag=0;
        else  choice=getch();
    }
    if(choice=='n'||choice=='N'){    /*开始游戏*/
        clear();
        move(10,25);
        addstr("BallGame will start! Are you read?");
        refresh();
        sleep(3);
        control();
    }
    else if(choice=='q'||choice=='Q'){   /*退出游戏*/
        clear();
        move(10,25);
        addstr("You quit the game successfully!");
        refresh();
        sleep(3);
        endwin();
    }
    endwin();  /*结束 curses*/
    return 0;
}
Example #15
0
int main(){

	int key;

	//Initialization and turn on keypad.
	initscr();

	crmode();

	keypad(stdscr, TRUE);

	//Close echo to prevent happening move of cursor after you press down key.
	//Clear the screen and display text.This program will wait for user to hit key.
	//The key's ascii value will display on screen unless the key is Q or error happened.
	
	noecho();

	clear();

	mvprintw(5, 5, "Key pad demonstration, Press 'q' to quit");

	move(7, 5);

	refresh();

	key = getch();

	while(key != ERR && key != 'q'){
		move(7, 5);
		clrtoeol();

		if((key >= 'A' && key <= 'Z') || (key >= 'a' && key <= 'z')){
			printw("Key was %c", (char)key);
		} else {
			switch(key){
				case LOCAL_ESCAPE_KEY : printw("%s", "Escape key"); break;
				case KEY_END: printw("%s", "END key");break;
				case KEY_BEG: printw("%s", "BEGINNING KEY"); break;
				case KEY_RIGHT: printw("%s", "RIGHT KEY"); break;
				case KEY_LEFT: printw("%s", "LEFT KEY"); break;
				case KEY_UP: printw("%s", "UP KEY"); break;
				case KEY_DOWN: printw("%s", "DOWN KEY"); break;
				default: printw("Unmatched - %d", key); break;
			}
		}

		refresh();
		key = getch();
	}

	endwin();

	exit(EXIT_SUCCESS);
}
Example #16
0
void setup()
{

     initscr();
     clear();
     noecho();
     crmode();
     curs_set(0);
     
     snake_init();
     food_create();
     snake_show_or_hide(SNAKE_BODY);
}
Example #17
0
/* Setup all elements and undeclared globals */
int setup(struct element elmts[])
{
	int i;
	srand(getpid());

	score = 0;
	escape = 0;

	/* Setup array of elements */
	for(i=0 ; i<NUMALL; i++){
		// setup the player
		if (i == 0) {
			elmts[i].str = "|";
			elmts[i].type = 0;
			elmts[i].alive = 1;
			elmts[i].respawn = 1;
			elmts[i].row = LINES-2;
			elmts[i].col = 1;
			elmts[i].delay = 1;
		}
		// setup the saucers
		else if (i < MAXSCR+1) {
			elmts[i].str = "<--->";
			elmts[i].type = 1;
			elmts[i].alive = 0;
			elmts[i].respawn = 1+(rand()%100);
			elmts[i].row = 1+(rand()%ROWSCRS);
			elmts[i].col = 0;
			elmts[i].delay = 1+(rand()%20);
		} 
		// setup the bullets
		else {
			elmts[i].str = "^";
			elmts[i].type = 2;
			elmts[i].alive = 0;
			elmts[i].respawn = 0;
			elmts[i].row = 0;
			elmts[i].col = 0;
			elmts[i].delay = 5;
		}
	}

	/* set up curses */
	initscr();
	crmode();
	noecho();
	clear();
	return 0;
}
Example #18
0
initscreen()
{
	/* initscr() already done in SCREENTEST() */
	view_w = newwin(VIEW_Y, VIEW_X, VIEW_T, VIEW_L);
	slot_w = newwin(SLOT_Y, SLOT_X, SLOT_T, SLOT_L);
	scroll_w = newwin(SCROLL_Y, SCROLL_X, SCROLL_T, SCROLL_L);
	stat_w = newwin(STAT_Y, STAT_X, STAT_T, STAT_L);
	turn_w = newwin(TURN_Y, TURN_X, TURN_T, TURN_L);
	done_curses++;
	(void) leaveok(view_w, 1);
	(void) leaveok(slot_w, 1);
	(void) leaveok(stat_w, 1);
	(void) leaveok(turn_w, 1);
	noecho();
	crmode();
}
Example #19
0
File: yf.c Project: ntufar/yargitay
/*
 * Yargitay Forms kutuphanesi kuruluyor, curses ilgili
 * parametreler belirtiliyor, signal handler'ler
 * tutuluyor.
 */
int inityf()
{
    initscr();
    crmode();
    nl();
    noecho();
    /*nocbreak();*/
    /*nodelay(stdscr,1);*/
    /*keypad(stdscr,1);*/
    scrollok(stdscr,1);
    attrset(A_NORMAL);
    signal(SIGQUIT,SIG_IGN);
    signal(SIGINT,SIG_IGN);
    signal(SIGABRT,SIG_IGN);
    signal(SIGHUP,SIG_DFL);
}
Example #20
0
/*
 * Set up curses, catch the appropriate signals,
 * and build the various windows.
 */
void
init_display(void)
{
    struct sigaction sa;

    if (initscr() == NULL)
        errx(1, "Terminal type unset or lacking necessary features.");
    (void) sigaction(SIGTSTP, NULL, &sa);
    sigaddset(&sa.sa_mask, SIGALRM);
    (void) sigaction(SIGTSTP, &sa, NULL);
    curses_initialized = 1;
    clear();
    refresh();
    noecho();
    crmode();
    signal(SIGINT, sig_sent);
    signal(SIGPIPE, sig_sent);
    /* curses takes care of ^Z */
    my_win.x_nlines = LINES / 2;
    my_win.x_ncols = COLS;
    my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0);
    idlok(my_win.x_win, TRUE);
    scrollok(my_win.x_win, TRUE);
    wclear(my_win.x_win);

    his_win.x_nlines = LINES / 2 - 1;
    his_win.x_ncols = COLS;
    his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols,
                           my_win.x_nlines+1, 0);
    idlok(my_win.x_win, TRUE);
    scrollok(his_win.x_win, TRUE);
    wclear(his_win.x_win);

    line_win = newwin(1, COLS, my_win.x_nlines, 0);
#if defined(hline) || defined(whline) || defined(NCURSES_VERSION)
    whline(line_win, 0, COLS);
#else
    box(line_win, '-', '-');
#endif
    wrefresh(line_win);
    /* let them know we are working on it */
    current_state = "No connection yet";
}
int main() {
    int key;
    initscr();
    crmode();  // this is a synonym for nocbreak(); - normal line buffering
               // mode. But I think it was actually a typo for the authors
               // to have this... what you really want is cbreak() so that
               // individual characters may be read.
    cbreak();
    keypad(stdscr, TRUE); // the true enables curses to automatically translate
                          // function keys, such as arrow keys, into logical
                          // values such as KEY_LEFT.
    noecho();
    clear();
    mvprintw(5, 5, "Key pad demonstration. Press 'q' to quit.");
    move(7, 5);
    refresh();
    key = getch();

    while (key != ERR && key != 'q') {
        move(7, 5);
        clrtoeol(); // carriage return to eol
        if ((key >= 'A' && key <= 'Z') ||
            (key >= 'a' && key <= 'z')) {
            printw("Key was '%c'", (char) key);
        } else {
            switch (key) {
                case LOCAL_ESCAPE_KEY: printw("%s", "Escape key"); break;
                case KEY_END: printw("%s", "End key key"); break;
                case KEY_BEG: printw("%s", "Beginning key"); break;
                case KEY_RIGHT: printw("%s", "Right key"); break;
                case KEY_LEFT: printw("%s", "Left key"); break;
                case KEY_UP: printw("%s", "Up key"); break;
                case KEY_DOWN: printw("%s", "Down key"); break;
            }
        }
        refresh();
        key = getch();

    }

    endwin();
    exit(EXIT_SUCCESS);
}
Example #22
0
main()
{
	int i, j, c;
	size_t len;
	char id[100];
	FILE *fp;
	char *s;

	initscr();			/* Always call initscr() first */
	signal(SIGINT, quit);		/* Make sure wou have a 'cleanup' fn */
	crmode();			/* We want cbreak mode */
	noecho();			/* We want to have control of chars */
	delwin(stdscr);			/* Create our own stdscr */
	stdscr = newwin(YSIZE, XSIZE, 10, 35); 
	flushok(stdscr, TRUE);		/* Enable flushing of stdout */
	scrollok(stdscr, TRUE);		/* Enable scrolling */
	erase();			/* Initially, clear the screen */

	standout();
	move(0,0);
	while (1) {
		c = getchar();
		switch(c) {
		case 'q':		/* Quit on 'q' */
			quit();
			break;
		case 's':		/* Go into standout mode on 's' */
			standout();
			break;
		case 'e':		/* Exit standout mode on 'e' */
			standend();
			break;
		case 'r':		/* Force a refresh on 'r' */
			wrefresh(curscr);
			break;
		default:		/* By default output the character */
			addch(c);
			refresh();
		}
	}
}
Example #23
0
void set_up( void )
{
  the_ball.y_pos = Y_INT;
  the_ball.x_pos = X_INT;
  the_ball.y_ttg = the_ball.y_ttm = Y_TTM;
  the_ball.x_ttg = the_ball.x_ttm = X_TTM;
  the_ball.y_dir = 1;
  the_ball.x_dir = 1;
  the_ball.symbol = DEF_SYMBOL;

  initscr();
  noecho();
  crmode();

  signal( SIGINT, SIG_IGN );
  mvaddch( the_ball.y_pos, the_ball.x_pos, the_ball.symbol );
  refresh();

  signal( SIGALRM, ball_move );
  set_ticker( 1000 / TICKS_PER_SEC );
}
Example #24
0
void init() {
    setenv("TERM", "xterm-256color", 1);
    setlocale(LC_ALL, "");
    initscr();
    start_color();
    keypad(stdscr, TRUE);
    crmode();
    noecho();
    curs_set(0);
    timeout(0);
#ifdef __linux__
    system("resize -s 55 170");
#endif
    for (int i = 0; i < static_cast<int>(Color::SIZE); i++) {
        init_pair(i + 1, COLOR_WHITE, i);
    }
    init_color(Color::DARK_RED);
    init_color(Color::DARK_YELLOW);
    init_color(Color::DARK_MAGENTA);
    init_color(Color::DARK_BLUE);
}
Example #25
0
void set_up()
{
   ball.y_pos = Y_INIT;
   ball.x_pos = X_INIT;
   ball.y_ttg = ball.y_ttm = Y_TTM;
   ball.x_ttg = ball.x_ttm = X_TTM;
   ball.y_dir = 1;
   ball.x_dir = 1;
   ball.symbol = DFL_SYMBOL;

   initscr();
   noecho();
   crmode();

   signal( SIGINT, SIG_IGN );
   mvaddch( ball.y_pos, ball.x_pos, ball.symbol );
   refresh();

   signal( SIGALRM, ball_move );
   set_ticker( 1000 / TICKS_PER_SEC );
}
Example #26
0
File: keypad1.c Project: shixv/test
int main(void)
{
	int key;

	initscr();
	crmode();
	keypad(stdscr,true);

	noecho();
	clear();
	mvprintw(5,5,"Key pad demonstratioin. press 'q' to quit");
	move(7,5);
	refresh();
	key=getch();

	while(key!=ERR&&key!='q'){
		move(7,5);
		clrtoeol();

		if((key>='A'&&key<='Z')||(key>='a'&&key<='z')){
			printw("Key was %c",(char)key);
		}
		else{
			switch(key){
				case LOCAL_ESCAPE_KEY: printw("%s","Escape Key");break;
				case KEY_END: printw("%s","End key");break;
				case KEY_BEG: printw("%s","BEGINING key");break;
				case KEY_RIGHT: printw("%s","RIGHT KEY");break;
				case KEY_LEFT: printw("%s","LEFT KEY");break;
				case KEY_UP: printw("%s","UP KEY");break;
				case KEY_DOWN: printw("%s","DOWN KEY");break;
				default: printw("Unmatched - %d",key);break;
			}
		}
		refresh();
		key=getch();
	}
	endwin();
	exit(EXIT_SUCCESS);
}
Example #27
0
int
escapade()
{
    register char *s;
    bool interactive = (buf[1] == FINISHCMD);
    bool docd;
    char whereiam[512];

    if (!finish_command(interactive))	/* get remainder of command */
	return -1;
    s = buf+1;
    docd = *s != '!';
    if (!docd) {
	s++;
    }
    else {
	getwd(whereiam);
	if (chdir(cwd)) {
	    printf(nocd,cwd) FLUSH;
	    sig_catcher(0);
	}
    }
    while (*s == ' ') s++;
					/* skip leading spaces */
    interp(cmd_buf, (sizeof cmd_buf), s);/* interpret any % escapes */
    resetty();				/* make sure tty is friendly */
    doshell(Nullch,cmd_buf);	/* invoke the shell */
    noecho();				/* and make terminal */
    crmode();				/*   unfriendly again */
    if (docd) {
	if (chdir(whereiam)) {
	    printf(nocd,whereiam) FLUSH;
	    sig_catcher(0);
	}
    }
#ifdef MAILCALL
    mailcount = 0;			/* force recheck */
#endif
    return 0;
}
Example #28
0
int main(int argc, char *argv[]){
	int MaxH,MaxW;						/*max high and width*/
	int i;
	LIFE life_pt[LIFEMAXW*LIFEMAXH];
	GAMEINFO info;


	srand((unsigned)time(NULL));
	for(i=0;i<LIFEMAXW*LIFEMAXH;i++){
		if((int)rand()%DENSITY==0)
		life_pt[i].live=1;
		else 
		life_pt[i].live=0;
		life_pt[i].x=i%LIFEMAXW+FORIGINX;
		life_pt[i].y=i/LIFEMAXW+FORIGINX;
	}
	info.speed=100000;
	/* life_pt[320].live=0;life_pt[321].live=1;life_pt[322].live=0; */
	/* life_pt[470].live=0;life_pt[471].live=1;life_pt[473].live=0; */
	/* life_pt[620].live=0;life_pt[621].live=1;life_pt[623].live=0; */
	initscr();
	crmode();
	noecho();
	cbreak();
	keypad(stdscr,TRUE);
	clear();
	if(argc>1){
		fprintf(stderr,"Don't use arguments\n");
		return 1;
	}
	timeout(0);
	simmain(life_pt,info);
	getmaxyx(stdscr,MaxH,MaxW);
	clear();
	mvprintw(0,0,"h%d :w%d\n",MaxH,MaxW);
	refresh();
	sleep(1);
	endwin();
	return 0;
}
void tge_initialize_screen(void) {
    assert(game_window.initialized == false);

    if ( game_window.initialized == false ) {
        if ( (game_window.window = initscr()) == NULL ) {
            perror("worms: couldn't initialize screen");
            exit(EXIT_FAILURE);
        }

        if ( ioctl(0, TIOCGWINSZ, &game_window.ws) == -1 ) {
            perror("worms: couldn't get terminal size");
            exit(EXIT_FAILURE);
        }

        noecho();
        keypad(game_window.window, true);
        crmode();
        game_window.old_cursor = curs_set(0);
        game_window.initialized = true;
        refresh();
    }
}
Example #30
0
int
main(void)
{
    int delay;
    int ndelay;
    int c;
    void move_msg(int);
    int set_ticker(int);

    initscr();
    crmode();
    noecho();
    clear();

    row = 10;
    col = 0;
    dir = 1;
    delay = 200;

    move(row,col);
    addstr(MESSAGE);
    signal(SIGALRM,move_msg);
    set_ticker(delay);

    while(1)
    {
            ndelay = 0;
            c = getchar();
            if (c == 'Q') break;
            if (c == ' ')dir = -dir;
            if (c == 'f' && delay > 2) ndelay = delay/2;
            if (c == 's') ndelay = delay * 2;
            if (ndelay > 0)
                set_ticker(delay = ndelay);
            }
    endwin();
    return 0;
}