コード例 #1
0
ファイル: menu.c プロジェクト: CheriPai/typespeed
/* Draws main menu onto screen. */
void
drawmenu(void)
{
	drawscreen();

	mvaddstr( 3, 30, "Typespeed ");
	addstr(TVERSION);

	mvaddstr( 5, 30, _("1. Test Your Speed"));
	if (opt.net == NET)
		mvaddstr( 6, 30, _("2. Close Connection"));
	else
		mvaddstr( 6, 30, _("2. Network Head2Head"));
	mvaddstr( 7, 30, _("3. Story/Credits/RTFM!"));
	mvaddstr( 8, 30, _("4. Show Highscores"));
	mvaddstr( 9, 30, _("5. Options"));
	mvaddstr(10, 30, _("6. Game Rules"));
	mvaddstr(11, 30, _("7. Quit"));

	mvaddstr(13, 30, _("Choose: "));
}
コード例 #2
0
ファイル: graphics.c プロジェクト: sundargates/qed-examples
static void zoom(int bnum, void (*drawscreen) (void)) {
/* Zooms in or out by a factor of 1.666. */

 float xdiff, ydiff;

 xdiff = xright - xleft; 
 ydiff = ybot - ytop;
 if (strcmp(button[bnum].text,"Zoom In") == 0) {
    xleft += xdiff/5.;
    xright -= xdiff/5.;
    ytop += ydiff/5.;
    ybot -= ydiff/5.;
 }
 else {
    xleft -= xdiff/3.;
    xright += xdiff/3.;
    ytop -= ydiff/3.;
    ybot += ydiff/3.;
 }
 update_transform ();
 drawscreen();
}
コード例 #3
0
ファイル: graphics.c プロジェクト: sundargates/qed-examples
static void update_win (int x[2], int y[2], void (*drawscreen)(void)) {
 float x1, x2, y1, y2;
 
 x[0] = min(x[0],top_width-MWIDTH);  /* Can't go under menu */
 x[1] = min(x[1],top_width-MWIDTH);
 y[0] = min(y[0],top_height-T_AREA_HEIGHT); /* Can't go under text area */
 y[1] = min(y[1],top_height-T_AREA_HEIGHT);

 if ((x[0] == x[1]) || (y[0] == y[1])) {
    printf("Illegal (zero area) window.  Window unchanged.\n");
    return;
 }
 x1 = XTOWORLD(min(x[0],x[1]));
 x2 = XTOWORLD(max(x[0],x[1]));
 y1 = YTOWORLD(min(y[0],y[1]));
 y2 = YTOWORLD(max(y[0],y[1]));
 xleft = x1;
 xright = x2;
 ytop = y1;
 ybot = y2;
 update_transform();
 drawscreen();
}
コード例 #4
0
ファイル: signal.c プロジェクト: AhmadTux/DragonFlyBSD
static void
tstop(void) /* control Y */
{
	if (nosignal)		/* nothing if inhibited */
		return;
	lcreat(NULL);
	clearvt100();
	lflush();
	signal(SIGTSTP, SIG_DFL);
#ifdef SIGVTALRM
	/* looks like BSD4.2 or higher - must clr mask for signal to take effect*/
	sigsetmask(sigblock(0) & ~BIT(SIGTSTP));
#endif
	kill(getpid(), SIGTSTP);

	setupvt100();
	signal(SIGTSTP, (sig_t)tstop);
	if (predostuff == 1)
		s2choose();
	else
		drawscreen();
	showplayer();
	lflush();
}
コード例 #5
0
ファイル: yaed.c プロジェクト: BackupTheBerlios/yaed
/* editor event loop */
int editor_loop()
{
	int ch;
	file_t *file;
	
	file = files[current];
	
	ch = getch();
	switch(ch)
	{
	case KEY_RESIZE:
		getmaxyx(screen, h, w);
		
		drawmenu();	
		drawscreen();
		break;
	
	case KEY_F(5):
		/* display help */
		drawhelp();
		refresh();
		
		while(!help_loop());
		
		drawscreen();
		break;
	
	case KEY_F(6):
		/* save */
		if(file->filename[0])
		{
			writefile(file, file->filename);
			file->saved = 1;
		}
		break;
	
	case KEY_F(8):
		/* force quit */
		return 1;
	
	case KEY_F(9):
		/* toggle linenumbers */
		show_linenumbers = !show_linenumbers;
		drawscreen();
		break;
	
	case KEY_F(10):
		/* tab size */
		tab_size = !tab_size;
		drawscreen();
		break;
	
	case KEY_F(11):
		/* C highlight */
		c_highlight = !c_highlight;
		drawscreen();
		break;
	
	case 3:			/* control-C */
		if(file->selected)
		{
			/* TODO: copy */
		}
		break;
	
	case 11:		/* control-K */
		if(file->line_count > 1)
			removeline(file, file->cursor_y);
		break;
	
	case 22:		/* control-V */
		/* TODO: paste */
		break;
	
	case 24:		/* control-X */
		/* quit */
		
		/* TODO: check all open files */
		
		if(file->saved)
			return 1;
		break;
		
	case 19:		/* control-S */
		if(file->selected)
		{
			int y;
			
			/* end selection */
			
			file->selected = 0;
			for(y = file->sel_begin_y; y <= file->sel_end_y; y++)
				drawline(file, y);
		}
		else
		{
			/* begin selection */
			
			file->selected = 1;
			file->sel_begin_x = file->cursor_x;
			file->sel_begin_y = file->cursor_y;
			file->sel_end_x = file->cursor_x;
			file->sel_end_y = file->cursor_y;
		}
		break;
	
	case 21:		/* control-U */
		if(file->selected)
		{
			int y;
			
			/* un-indent lines */
			
			for(y = file->sel_begin_y; y <= file->sel_end_y; y++)
			{
				if(file->lines[y].len && file->lines[y].buf[0] == '\t')
					removetext(file, 0, y, 1);
			}
		}
		break;
	
	case KEY_PPAGE:
		/* move half screen up */
		if(file->cursor_y)
		{
			file->cursor_y -= h/2;
			if(file->cursor_y < 0)
				file->cursor_y = 0;
			
			/* don't go past end of line */
			if(file->cursor_x > file->lines[file->cursor_y].len)
				file->cursor_x = file->lines[file->cursor_y].len;
		}
		break;
	
	case KEY_NPAGE:
		/* move half screen down */
		if(file->cursor_y < file->line_count-1)
		{
			file->cursor_y += h/2;
			if(file->cursor_y > file->line_count-1)
				file->cursor_y = file->line_count-1;
			
			/* don't go past end of line */
			if(file->cursor_x > file->lines[file->cursor_y].len)
				file->cursor_x = file->lines[file->cursor_y].len;
		}
		break;
	
	case KEY_UP:
		if(file->cursor_y)
		{
			file->cursor_y--;
			
			/* don't go past end of line */
			if(file->cursor_x > file->lines[file->cursor_y].len)
				file->cursor_x = file->lines[file->cursor_y].len;
		}
		break;
	
	case KEY_DOWN:
		if(file->cursor_y < file->line_count-1)
		{
			file->cursor_y++;
			
			/* move cursor to line end */
			if(file->cursor_x > file->lines[file->cursor_y].len)
				file->cursor_x = file->lines[file->cursor_y].len;
		}
		break;
	
	case KEY_HOME:
		/* go to begin of line */
		if(file->cursor_x)
			file->cursor_x = 0;
		break;
	
	case KEY_END:
		/* go to end of line */
		if(file->cursor_x < file->lines[file->cursor_y].len)
			file->cursor_x = file->lines[file->cursor_y].len; 
		break;
	
	case KEY_LEFT:
		/* go to left one character */
		if(file->cursor_x)
			file->cursor_x--;
		else if(file->cursor_y)
		{
			/* jump to end of previous line */
			file->cursor_y--;
			file->cursor_x = file->lines[file->cursor_y].len;
		}
		break;
	
	case KEY_RIGHT:
		/* go right one character */
		if(file->cursor_x < file->lines[file->cursor_y].len)
			file->cursor_x++;
		else if(file->cursor_y < file->line_count-1)
		{
			/* jump to begin of next line */
			file->cursor_y++;
			file->cursor_x = 0;
		}
		break;
	
	case KEY_DC:
		if(file->selected)
		{
			file->selected = 0;
			
			/* delete selection */
			
			if(file->sel_begin_y == file->sel_end_y)
			{
				/* remove characters from current line */
				removetext(file, file->sel_begin_x, file->sel_begin_y,
					file->sel_end_x - file->sel_begin_x);
			}
			else
			{
				int y;
				line_t *line;
				
				/* remove ending from the first line */
				removetext(file, file->sel_begin_x, file->sel_begin_y,
					file->lines[file->sel_begin_y].len - file->sel_begin_x);
				
				/* copy ending from the last line to the end of first line */
				line = &file->lines[file->sel_end_y];
				if(file->sel_end_x < line->len)
				{
					inserttext(file, file->sel_begin_x, file->sel_begin_y,
						&line->buf[file->sel_end_x],
						line->len - file->sel_end_x);
				}
				
				/* remove all lines between the first and last line */
				for(y=0; y < file->sel_end_y-file->sel_begin_y; y++)
					removeline(file, file->sel_begin_y+1);
				
				file->cursor_x = file->sel_begin_x;
				file->cursor_y = file->sel_begin_y;
			}
		}
		else if(file->cursor_x < file->lines[file->cursor_y].len)
		{
			/* remove character from cursor position */
			removetext(file, file->cursor_x, file->cursor_y, 1);
		}
		break;
	
	case KEY_BACKSPACE:
	case '\b':
	case 127:
		if(file->cursor_x)
		{
			/* remove character from cursor position */
			file->cursor_x--;
			removetext(file, file->cursor_x, file->cursor_y, 1);
		}
		else if(file->cursor_y)
		{
			line_t *line;
			
			/* move to the end of the previous line */
			file->cursor_y--;
			file->cursor_x = file->lines[file->cursor_y].len;
			
			/* copy text from the next line to the end of current line */
			
			line = &file->lines[file->cursor_y+1];
			if(line->len)
			{
				inserttext(file, file->cursor_x, file->cursor_y,
					line->buf, line->len);
			}
			
			/* and remove the next line */
			removeline(file, file->cursor_y+1);
		}
		break;
	
	case '\r':
		{
			line_t *line;
			
			/* add new line */
			insertline(file, file->cursor_y+1);
			
			line = &file->lines[file->cursor_y];
			if(file->cursor_x < line->len)
			{
				/* copy ending from the current line to the next line */
				inserttext(file, 0, file->cursor_y+1,
					&line->buf[file->cursor_x], line->len - file->cursor_x);
				
				/* and remove ending from the current line */
				removetext(file, file->cursor_x, file->cursor_y,
					line->len - file->cursor_x);
			}
			
			/* move cursor to the begin of the next line */
			file->cursor_y++;
			file->cursor_x = 0;
		}
		break;
	
	case '\t':
		if(file->selected)
		{
			int y;
			
			/* indent lines */
			
			for(y = file->sel_begin_y; y <= file->sel_end_y; y++)
				inserttext(file, 0, y, "\t", 1);
			
			break;
		}
		/* fall trought */
	
	default:
		if((ch >= ' ' && ch < 256) || ch == '\t')
		{
			unsigned char buf = ch;
			
			/* insert character at cursor position */
			inserttext(file, file->cursor_x, file->cursor_y,
				(const char *)&buf, 1);
			file->cursor_x++;
		}
		break;
	}
	
	cursormoved(file);
	
	setcursor();
	refresh();
	
	return 0;
}
コード例 #6
0
ファイル: yaed.c プロジェクト: BackupTheBerlios/yaed
void cursormoved(file_t *file)
{
	if(file->cursor_y >= file->scroll_y + h-1-3)
	{
		/* scroll screen up */
		while(file->cursor_y >= file->scroll_y + h-1-h/3)
		{
			file->scroll_y++;
			
			if(current >= 0 && file == files[current])
			{
				/* scroll screen */
				
				scrollok(screen, TRUE);
				scrl(1);
				scrollok(screen, FALSE);
				
				/* draw bottom line */
				if(h-2 + file->scroll_y < file->line_count)
					drawline(file, h-2 + file->scroll_y);
				
				drawmenu();
				refresh();
				
				napms(5);
			}
		}
	}
	
	if(file->cursor_y < file->scroll_y + 3 && file->scroll_y)
	{
		/* scroll screen down */
		while(file->cursor_y < file->scroll_y + h/3 && file->scroll_y)
		{
			file->scroll_y--;
			
			if(current >= 0 && file == files[current])
			{
				/* scroll screen */
				
				scrollok(screen, TRUE);
				scrl(-1);
				scrollok(screen, FALSE);
				
				/* draw top line */
				
				drawline(file, file->scroll_y);
				drawmenu();
				refresh();
				
				napms(5);
			}
		}
	}
	
	/* modify selection */
	if(file->selected && ((file->cursor_x >= file->sel_begin_x
	&& file->cursor_y == file->sel_begin_y) || file->cursor_y > file->sel_begin_y))
	{
		file->sel_end_x = file->cursor_x;
		file->sel_end_y = file->cursor_y;
		
		if(current >= 0 && file == files[current])
			drawscreen();
	}
	
	if(current >= 0 && file == files[current])
		drawpos();
}
コード例 #7
0
ファイル: object.c プロジェクト: joshbressers/ularn
void ohome()
{
	int i;

	nosignal = 1;	/* disable signals */
	for (i=0; i<IVENSIZE; i++) 
		/* remove the potion of cure dianthroritis from inventory */
		if (iven[i]==OPOTION) 
			if (ivenarg[i]==21) {   
				iven[i]=0;	
				clear(); 
				lprcat("Congratulations.  You found the potion of cure "
					   "dianthroritis!\n");
				lprcat("\nFrankly, No one thought you could do it.");
				lprcat("  Boy!  Did you surprise them!\n");
				nap(1000);
				if (gtime>TIMELIMIT) {
					lprcat("\nHowever... the doctor has the sad duty to "
						   "inform you that your daughter has\n");
					lprcat("died! You didn't make it in time.  In your agony, "
						   "you kill the doctor,\nyour ");
					if (sex == 1)
						lprcat("wife");
					else
						lprcat("husband");
					lprcat(" and yourself!  Too bad...\n");
					nap(5000); 
					died(269);
				}
				else {
					lprcat("\nThe doctor is now administering the potion and, "
						   "in a few moments,\n");
					lprcat("your daughter should be well on her way to "
						   "recovery.\n");
					nap(6000);
					lprcat("\nThe potion is."); 
					nap(1000); 
					lprcat(".");
					nap(1000); 
					lprcat(".");
					nap(1000); 
					lprcat(" working!  The doctor thinks that\n");
					lprcat("your daughter will recover in a few days.  "
						   "Congratulations!");
					beep(); 
					nap(5000); 
					died(263);
				}
			}

	while (1) {
		clear();
		lprintf("Welcome home %s.",logname);
		lprcat("  Latest word from the doctor is not good.\n");

		if (gtime>TIMELIMIT) {
			lprcat("\nThe doctor has the sad duty to inform you that your "
				   "daughter has died!\n");
			lprcat("You didn't make it in time.");
			lprcat("In your agony, you kill the doctor,\nyour ");
			if (sex == 1)
				lprcat("wife");
			else
				lprcat("husband");
			lprcat(" and yourself!  Too bad...");
			nap(5000); 
			died(269);
		}

		lprcat("\nThe diagnosis is confirmed as dianthroritis.  "
			   "He guesses that\n");
		lprintf("your daughter has only %d mobuls left in this world.  "
				"It's up to you,\n",(long)((TIMELIMIT-gtime+99)/100));
		lprintf("%s, to find the only hope for your daughter, the very rare\n",
				logname);
		lprcat("potion of cure dianthroritis.  It is rumored that only deep "
			   "in the\n");
		lprcat("depths of the caves can this potion be found.\n\n\n");
		lprcat("\n     ----- press "); 
		ularn_standout("return");
		lprcat(" to continue, "); 
		ularn_standout("escape");
		lprcat(" to leave ----- ");
		i=getcharacter();  
		while (i!=ESC && i!='\n') 
			i=getcharacter();
		if (i==ESC) { 
			drawscreen(); 
			nosignal = 0; /* enable signals */

			return; 
		}
	}
}
コード例 #8
0
ファイル: command1.c プロジェクト: albert-wang/OmegaRPG
/* deal with a new player command in countryside mode */
void p_country_process(void)
{
    int no_op;

    drawvision(Player.x,Player.y);
    do {
        no_op = FALSE;
        Cmd = mgetc();
        clear_if_necessary();
        switch (Cmd) {
        case ' ':
        case 13:
            no_op = TRUE;
            break;
        case 7:
            wizard();
            break; /* ^g */
        case 12:
            xredraw();
            no_op = TRUE;
            break; /* ^l */
#if !defined(WIN32)
        case 16:
            bufferprint();
            no_op = TRUE;
            break; /* ^p */
#else
        case 15:
            bufferprint();
            no_op = TRUE;
            break; /* ^o */
#endif
        case 18:
            redraw();
            no_op = TRUE;
            break; /* ^r */
        case 23:
            if (gamestatusp(CHEATED)) drawscreen();
            break; /* ^w */
        case 24:
            if (gamestatusp(CHEATED) ||
                    Player.rank[ADEPT]) wish(1);
            break; /* ^x */
        case 'd':
            drop();
            break;
        case 'e':
            eat();
            break;
        case 'i':
            do_inventory_control();
            break;
        case 's':
            countrysearch();
            break;
        case 'x':
            examine();
            break;
        case 'E':
            dismount_steed();
            break;
        case 'H':
            hunt(Country[Player.x][Player.y].current_terrain_type);
            break;
        case 'I':
            if (! optionp(TOPINV)) top_inventory_control();
            else {
                menuclear();
                display_possessions();
                inventory_control();
            }
            break;
        case 'O':
            setoptions();
            break;
        case 'P':
            show_license();
            break; /* actually show_license is in file.c */
        case 'Q':
            quit();
            break;
        case 'R':
            rename_player();
            break;
        case 'S':
            save(FALSE);
            break;
        case 'V':
            version();
            break;
        case '>':
            enter_site(Country[Player.x][Player.y].base_terrain_type);
            break;
        case '#':
            if (gamestatusp(CHEATED)) editstats();
            break; /* RAC - char editor */
        case '/':
            charid();
            no_op = TRUE;
            break;
        case '?':
            help();
            no_op = TRUE;
            break;
        case '4':
        case 'h':
            movepincountry(-1,0);
            break;
        case '2':
        case 'j':
            movepincountry(0,1);
            break;
        case '8':
        case 'k':
            movepincountry(0,-1);
            break;
        case '6':
        case 'l':
            movepincountry(1,0);
            break;
        case '1':
        case 'b':
            movepincountry(-1,1);
            break;
        case '3':
        case 'n':
            movepincountry(1,1);
            break;
        case '7':
        case 'y':
            movepincountry(-1,-1);
            break;
        case '9':
        case 'u':
            movepincountry(1,-1);
            break;
        default:
            commanderror();
            no_op = TRUE;
            break;
        }
    } while (no_op);
    screencheck(Player.x,Player.y);
}
コード例 #9
0
ファイル: CALCI.CPP プロジェクト: rahulsend89/cprograming
//start of main
void main()
{
//getch();
  initialize();      //initialises graphics mode
  setcolor(RED);     //sets text color red
  mainscreen();      //draws format for calculator
  mouse m;           //creates mouse object
  char string[100];
  int button,xx,yy,flag=0,index,i;
  int counter;
  int matrix[5][3]={{0,1,2},{3,4,5},{6,7,8},{9,10,11},{12,13,14}};
  int count=0;
  //setviewport(70,70,getmaxx()-80,100,1);
  //clearviewport();
  long double num[100],ii=0,rcount=0;
  drawscreen();         //creates output screen
  while(1)
  {


  counter=150;
  button=0;
  m.getmousepos(button,xx,yy);        //gets x&y position of mouse ptr

  if(((button & 1)==1)&&(flag==0))
    {
	for(int k=0;k<5;k++)
		{
		for(int x=400,i=0;x<=5*100;x+=50,i++)
			{
			if(xx>=x && xx<=x+30 && yy>=counter&&yy<=counter+20)
				{
				index=matrix[k][i];
				flag=1;
				//cout<<index;
				//delay(200);
				goto end;
				}
			}
		   counter+=40;
		}

    }

    end:
    //(430,350,500,375);
    if(((button & 1)==1)&&(flag==0))
    {
    if(xx>=430&&xx<=500&&yy>=350&&yy<=375)
    index=50;
    flag=1;
    }
    switch(index)
    {



    case 50:
	m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	 exit(0);
	}

    case 0:

	m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	//setcolor(WHITE);
       drawscreen();
	setcolor(WHITE);


	string[count]='9';
	num[ii]=9;
	ii++;
	//outtextxy(getmaxx()-(5*count+200),70,string);

	count++;
	string[count]='\0';
	outtextxy(getmaxx()-(200+5*count),70,string );
	//delay(0);
	flag=0;
	}
	break;

    case 1:

	m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	//setcolor(WHITE);
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"8" );


	string[count]='8';
	count++;
	string[count]='\0';
		num[ii]=8;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 2:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"7" );
	string[count]='7';
	count++;
	string[count]='\0';
		num[ii]=7;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 3:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"6" );
	string[count]='6';
	count++;
	string[count]='\0';
		num[ii]=6;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 4:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
       //	outtextxy(getmaxx()-100,70,"5" );
       string[count]='5';
	count++;
	string[count]='\0';
		num[ii]=5;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 5:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"4" );
	string[count]='4';
	count++;
	string[count]='\0';
		num[ii]=4;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 6:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"3" );
	string[count]='3';
	count++;
	string[count]='\0';
		num[ii]=3;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 7:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//+outtextxy(getmaxx()-100,70,"2" );
	string[count]='2';
	count++;
	string[count]='\0';
		num[ii]=2;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 8:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"1" );
	string[count]='1';
	count++;
	string[count]='\0';
		num[ii]=1;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 9:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"0" );
	string[count]='0';
	count++;
	string[count]='\0';
		num[ii]=0;
	ii++;
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 10:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"+" );
	string[count]='+';
	count++;
	string[count]='\0';
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 11:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);
	//outtextxy(getmaxx()-100,70,"-" );
	string[count]='-';
	count++;
	string[count]='\0';
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 12:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	clearscreen();

	setcolor(WHITE);
	//string[count]='/';
	//count++;
	//outtextxy(getmaxx()-100,70,"%" );
       //	string[count]='\0';
   //	outtextxy(getmaxx()-(200+5*count),70,string );
	count=0;
	flag=0;
	}
	break;
    case 13:
	  m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{
	drawscreen();
	setcolor(WHITE);

	string[count]='*';
	count++;
	string[count]='\0';
	outtextxy(getmaxx()-(200+5*count),70,string );
	flag=0;
	}
	break;
    case 14:
	char s1[100],s2[100];
	char * s11,s22;
	long double value=0;

	long double n1=0,n2=0;
	m.getmousepos(button,xx,yy);
	if(((button & 1)==0) && (flag==1))
	{

	drawscreen();
	setcolor(WHITE);


	for(int k=0;k<count;k++)
	{
	if(string[k]=='+'||string[k]=='-'||string[k]=='*'||string[k]=='-')
	{
	for(int p=0,q=k-1;p<k;p++,q--)
	{
	n1+=(num[p]*(pow(10,q)));

	}

	for(p=k,q=(ii-k-1);p<count-1;p++,q--)
	{

	 n2+=(num[p]*(pow(10,q)));

	}
	if(string[k]=='+')
	{
	value=(double)(n1+n2);

	break;
	}
	if(string[k]=='-')
	{
	value=(double)(n1-n2);
	break;
	}
	if(string[k]=='*')
	{
	value=(double)(n1*n2);
	break;
	}
       /*	if(string[k]=='cls')
	{
	value=(double)(n1/n2);
	break;
	}*/
	}
	}

	int ndig=0,dec,sign;
	s11 = fcvt(value,ndig, &dec, &sign);//converts a num into string
       drawscreen();
       setcolor(WHITE);
	outtextxy(getmaxx()-(5*strlen(s11)+200),70,s11);
	rcount++;
	flag=0;
	count=0;

	ii=0;
	}
	break;

    }

  }
  //getch();
  restorecrtmode();       //restores textmode
}
コード例 #10
0
ファイル: menu.c プロジェクト: aztli/Traducciones
/* Draws multiplayer menu. */
void
multipmenu(void)
{
	int exitnow;
	char port[6], serv[MAXHOSTNAMELEN];

	exitnow = 0;
	serv[0] = '\0';

	do {
		drawscreen();
		mvaddstr(3, 30, "Typespeed ");
		addstr(TVERSION);

		mvaddstr( 5, 30, _("1. Server"));
		mvaddstr( 6, 30, _("2. Client"));
		mvaddstr( 7, 30, _("3. Port"));
		mvaddstr( 8, 30, _("4. Player Name"));
		mvaddstr( 9, 30, _("5. Return"));

		xcolor_set(5);
		mvprintw( 7, 50, "%d", opt.port);
		mvprintw( 8, 50, "%s", opt.name);
		mvaddstr(11, 30, _("Choose: "));

		switch (getch()) {
		case '1':
			serv[0] = '\0';
			exitnow = 1;
			break;
		case '2':
			mvaddstr(11, 30, _("Enter Host:"));
			liima_mvgetnstr(11, 31 +
			    strlen(_("Enter Host:")), serv,
			    sizeof(serv) - 1);
			serv[sizeof(serv) - 1] = '\0';
			exitnow = 1;
			break;
		case '3':
			mvaddstr(11, 30, _("Enter Port:"));
			liima_mvgetnstr(11, 31 + strlen(_("Enter Port:")), port,
			    sizeof(port) - 1);
			port[sizeof(port) - 1] = '\0';
			opt.port = strtol(port, NULL, 10);
			if (opt.port <= 1024)
				opt.port = 6025;
			exitnow = 0;
			break;
		case '4':
			mvaddstr(11, 30, _("Enter Name:"));
			liima_mvgetnstr(11, 31 +
			    strlen(_("Enter Name:")), opt.name,
			    sizeof(opt.name) - 1);
			opt.name[sizeof(opt.name) - 1] = '\0';
			exitnow = 0;
			break;
		case '5':
			return;
			/* NOTREACHED */
			break;
		default:
			break;
		}
	} while (!exitnow);

	drawscreen();
	mvaddstr(3, 30, "Typespeed ");
	addstr(TVERSION);

	mvaddstr(5, 30, _("When you get connect, choose a word list and"));
	mvaddstr(6, 30, _("then wait for the game start. The game starts as"));
	mvaddstr(7, 30, _("soon as the other player has chosen a word list."));
	refresh();

	initnetwork(serv, 1);
	flushinp();
}
コード例 #11
0
ファイル: menu.c プロジェクト: aztli/Traducciones
/* Prints file selection menu. */
int
fileselmenu(int tot, struct finfo *thingie, const char *title)
{
	int a, cpos, k;

	drawscreen();
	xcolor_set(4);
	mvprintw(2, 5, _("Choose a %s (UP/DOWN/ENTER):"), title);
	if (tot > 17)
		for (k = 0; k < 17; k++)
			mvaddstr(k + 4, 5, thingie[k].descr);
	else
		for (k = 0; k < tot; k++)
			mvaddstr(k + 4, 5, thingie[k].descr);

	cpos = k = 0;
	mvaddstr(4, 1, "->");

	for (a = 1; a;) {
		/*
		 * And thanks for xmunkki, he made my day and
		 * "solved" this, what i didn't get right (or did
		 * but i used 2 extra variables. :)
		 */
		switch (getch()) {
		case 27:
			return -1;
			break;
		case KEY_UP:
		case 'k':
			if (k <= 0)
				break;
			k--;
			if (cpos > 0) {
				cpos--;
				break;
			}
			move(20, 5);
			deleteln();
			move(4, 5);
			insertln();
			mvaddstr(4, 5, thingie[k].descr);
			break;
		case KEY_DOWN:
		case 'j':
			if (k > tot - 2)
				break;
			k++;
			if (cpos < 16 && cpos < tot - 1) {
				cpos++;
				break;
			}
			move(4, 5);
			deleteln();
			move(20, 5);
			insertln();
			mvaddstr(20, 5, thingie[k].descr);
			break;
		case ' ':
		case '\n':
			a = 0;
			break;
		default:
			break;
		}
		mvaddstr(cpos + 3, 1, "  ");
		mvaddstr(cpos + 5, 1, "  ");
		mvaddstr(cpos + 4, 1, "->");
	}

	return k;
}
コード例 #12
0
ファイル: main.c プロジェクト: HunterZ/larn
/*
 * parse()
 *
 * get and execute a command
 */
static void parse(void)
{
	int i, j, k, flag;

    while   (1)
        {
        k = yylex();
        switch(k)   /*  get the token from the input and switch on it   */
            {
            case 'h':   moveplayer(4);  return;     /*  west        */
            case 'H':   run(4);         return;     /*  west        */
            case 'l':   moveplayer(2);  return;     /*  east        */
            case 'L':   run(2);         return;     /*  east        */
            case 'j':   moveplayer(1);  return;     /*  south       */
            case 'J':   run(1);         return;     /*  south       */
            case 'k':   moveplayer(3);  return;     /*  north       */
            case 'K':   run(3);         return;     /*  north       */
            case 'u':   moveplayer(5);  return;     /*  northeast   */
            case 'U':   run(5);         return;     /*  northeast   */
            case 'y':   moveplayer(6);  return;     /*  northwest   */
            case 'Y':   run(6);         return;     /*  northwest   */
            case 'n':   moveplayer(7);  return;     /*  southeast   */
            case 'N':   run(7);         return;     /*  southeast   */
            case 'b':   moveplayer(8);  return;     /*  southwest   */
            case 'B':   run(8);         return;     /*  southwest   */

            case '.':                               /*  stay here       */
                if (yrepcount) 
                    viewflag=1;
                return;

            case 'c':
                yrepcount=0;
                cast();
                return;     /*  cast a spell    */

            case 'd':
                yrepcount=0;
                if (c[TIMESTOP]==0)
                    dropobj();
                return; /*  to drop an object   */

            case 'e':
                yrepcount=0;
                if (c[TIMESTOP]==0)
                    if (!floor_consume( OCOOKIE, "eat" ))
                        consume( OCOOKIE, "eat", showeat );
                return; /*  to eat a fortune cookie */

            case 'g':   
                yrepcount = 0 ;
                cursors();
                lprintf("\nThe stuff you are carrying presently weighs %d pounds",(long)packweight());
                break ;

            case 'i':       /* inventory */
                yrepcount=0;
                nomove=1;
                showstr(FALSE);
                return;

            case 'p':           /* pray at an altar */
                yrepcount = 0;
                    pray_at_altar();
                return;

            case 'q':           /* quaff a potion */
                yrepcount=0;
                if (c[TIMESTOP]==0)
                    if (!floor_consume( OPOTION, "quaff"))
                        consume( OPOTION, "quaff", showquaff );
                return;

            case 'r':
                yrepcount=0;
                if (c[BLINDCOUNT])
                    {
                    cursors();
                    lprcat("\nYou can't read anything when you're blind!");
                    }
                else if (c[TIMESTOP]==0)
                    if (!floor_consume( OSCROLL, "read" ))
                        if (!floor_consume( OBOOK, "read" ))
                            consume( OSCROLL, "read", showread );
                return;     /*  to read a scroll    */

            case 's':
                yrepcount = 0 ;
                    sit_on_throne();
                return ;

            case 't':                       /* Tidy up at fountain */
                yrepcount = 0 ;
                    wash_fountain() ;
                return ;

            case 'v':
                yrepcount=0;
                nomove = 1;
                cursors();
                lprintf("\nLarn, Version %d.%d.%d, Diff=%d",(long)VERSION,(long)SUBVERSION,(long)PATCHLEVEL,(long)c[HARDGAME]);
                if (wizard)
                    lprcat(" Wizard");
                if (cheat) 
                    lprcat(" Cheater");
                return;

            case 'w':                       /*  wield a weapon */
                yrepcount=0;
                wield();
                return;

            case 'A':
                yrepcount = 0;
                    desecrate_altar();
                return;

            case 'C':                       /* Close something */
                yrepcount = 0 ;
                    close_something();
                return;

            case 'D':                       /* Drink at fountain */
                yrepcount = 0 ;
                    drink_fountain() ;
                return ;

            case 'E':               /* Enter a building */
                yrepcount = 0 ;
                    enter() ;
                break ;

            case 'I':              /*  list spells and scrolls */
                yrepcount=0;
                seemagic(0);
                nomove=1;
                return;

            case 'O':               /* Open something */
                yrepcount = 0 ;
                    open_something();
                return;

            case 'P':
                cursors();
                yrepcount = 0;
                nomove = 1;
                if (outstanding_taxes>0)
                    lprintf("\nYou presently owe %d gp in taxes.",(long)outstanding_taxes);
                else
                    lprcat("\nYou do not owe any taxes.");
                return;

            case 'Q':    /*  quit        */
                yrepcount=0;
                quit();
                nomove=1;
                return;

            case 'R' :          /* remove gems from a throne */
                yrepcount = 0 ;
                    remove_gems( );
                return ;

            case 'S':
                /* And do the save.
                 */
                cursors();
                lprintf("\nSaving to `%s' . . . ", savefilename);
                lflush();
                save_mode = 1;
                savegame(savefilename);
                clear();
                lflush();
                wizard=1;
                died(-257); /* doesn't return */
                break;


            case 'T':   yrepcount=0;    cursors();  if (c[SHIELD] != -1) { c[SHIELD] = -1; lprcat("\nYour shield is off"); bottomline(); } else
                                        if (c[WEAR] != -1) { c[WEAR] = -1; lprcat("\nYour armor is off"); bottomline(); }
                        else lprcat("\nYou aren't wearing anything");
                        return;

            case 'W':
                yrepcount=0;
                wear();
                return; /*  wear armor  */

            case 'Z':
                yrepcount=0;
                if (c[LEVEL]>9) 
                    { 
                    oteleport(1);
                    return; 
                    }
                cursors(); 
                lprcat("\nAs yet, you don't have enough experience to use teleportation");
                return; /*  teleport yourself   */

            case ' ':   yrepcount=0;    nomove=1;  return;

            case 'L'-64:  yrepcount=0;  drawscreen();  nomove=1; return;    /*  look        */

#if WIZID
#ifdef EXTRA
            case 'A'-64:    yrepcount=0;    nomove=1; if (wizard) { diag(); return; }  /*   create diagnostic file */
                        return;
#endif
#endif
	    
	    case '<':                       /* Go up stairs or vol shaft */
                yrepcount = 0;
                    up_stairs();
                return ;

            case '>':                       /* Go down stairs or vol shaft*/
                yrepcount = 0 ;
                    down_stairs();
                return ;

            case '?':                       /* give the help screen */
                yrepcount=0;
                help();
                nomove=1;
                return; 

        case ',':                       /* pick up an item */
            yrepcount = 0 ;
            /* pickup, don't identify or prompt for action */
            lookforobject( FALSE, TRUE, FALSE );
        return;

            case ':':                       /* look at object */
                yrepcount = 0 ;
            /* identify, don't pick up or prompt for action */
                    lookforobject( TRUE, FALSE, FALSE );
                nomove = 1;  /* assumes look takes no time */
                return;

        case '/':        /* identify object/monster */
            specify_object();
            nomove = 1 ;
            yrepcount = 0 ;
            return;

        case '^':                       /* identify traps */
                flag = yrepcount = 0;
                cursors();
                lprc('\n');
                for (j=playery-1; j<playery+2; j++)
                    {
                    if (j < 0)
                        j=0;
                    if (j >= MAXY)
                        break;
                    for (i=playerx-1; i<playerx+2; i++)
                        {
                        if (i < 0) 
                            i=0;
                        if (i >= MAXX) 
                            break;
                        switch(item[i][j])
                            {
                            case OTRAPDOOR:     case ODARTRAP:
                            case OTRAPARROW:    case OTELEPORTER:
                            case OPIT:
                                lprcat("\nIts ");
                                lprcat(objectname[item[i][j]]);
                                flag++;
                            };
                        }
                    }
                if (flag==0) 
                    lprcat("\nNo traps are visible");
                return;

#if WIZID
            case '_':   /*  this is the fudge player password for wizard mode*/
                        yrepcount=0;    cursors(); nomove=1;

                        if (getpassword()==0)
                            {
                            scbr(); /* system("stty -echo cbreak"); */ return;
                            }
                        wizard=1;  scbr(); /* system("stty -echo cbreak"); */
                        for (i=0; i<6; i++)  c[i]=70;  iven[0]=iven[1]=0;
                        take(OPROTRING,50);   take(OLANCE,25);  c[WIELD]=1;
                        c[LANCEDEATH]=1;   c[WEAR] = c[SHIELD] = -1;
                        raiseexperience(6000000L);  c[AWARENESS] += 25000;
                        {
                        int i,j;
                        for (i=0; i<MAXY; i++)
                            for (j=0; j<MAXX; j++)  know[j][i]=KNOWALL;
                        for (i=0; i<SPNUM; i++) spelknow[i]=1;
                        for (i=0; i<MAXSCROLL; i++)  scrollname[i][0]=' ';
                        for (i=0; i<MAXPOTION; i++)  potionname[i][0]=' ';
                        }
                        for (i=0; i<MAXSCROLL; i++)
                          if (strlen(scrollname[i])>2) /* no null items */
                            { item[i][0]=OSCROLL; iarg[i][0]=i; }
                        for (i=MAXX-1; i>MAXX-1-MAXPOTION; i--)
                          if (strlen(potionname[i-MAXX+MAXPOTION])>2) /* no null items */
                            { item[i][0]=OPOTION; iarg[i][0]=i-MAXX+MAXPOTION; }
                        for (i=1; i<MAXY; i++)
                            { item[0][i]=i; iarg[0][i]=0; }
                        for (i=MAXY; i<MAXY+MAXX; i++)
                            { item[i-MAXY][MAXY-1]=i; iarg[i-MAXY][MAXY-1]=0; }
            for (i=MAXX+MAXY; i<MAXOBJECT; i++)
                {
                item[MAXX-1][i-MAXX-MAXY]=i;
                iarg[MAXX-1][i-MAXX-MAXY]=0;
                }
                        c[GOLD]+=250000;    drawscreen();   return;
#endif

            };
        }
}
コード例 #13
0
ファイル: main.c プロジェクト: ajinkya93/netbsd-src
/*
	parse()

	get and execute a command
 */
static void
parse(void)
{
	int    i, j, k, flag;
	while (1) {
		k = yylex();
		switch (k) {	/* get the token from the input and switch on
				 * it	 */
		case 'h':
			moveplayer(4);
			return;	/* west		 */
		case 'H':
			run(4);
			return;	/* west		 */
		case 'l':
			moveplayer(2);
			return;	/* east		 */
		case 'L':
			run(2);
			return;	/* east		 */
		case 'j':
			moveplayer(1);
			return;	/* south		 */
		case 'J':
			run(1);
			return;	/* south		 */
		case 'k':
			moveplayer(3);
			return;	/* north		 */
		case 'K':
			run(3);
			return;	/* north		 */
		case 'u':
			moveplayer(5);
			return;	/* northeast	 */
		case 'U':
			run(5);
			return;	/* northeast	 */
		case 'y':
			moveplayer(6);
			return;	/* northwest	 */
		case 'Y':
			run(6);
			return;	/* northwest	 */
		case 'n':
			moveplayer(7);
			return;	/* southeast	 */
		case 'N':
			run(7);
			return;	/* southeast	 */
		case 'b':
			moveplayer(8);
			return;	/* southwest	 */
		case 'B':
			run(8);
			return;	/* southwest	 */

		case '.':
			if (yrepcount)
				viewflag = 1;
			return;	/* stay here		 */

		case 'w':
			yrepcount = 0;
			wield();
			return;	/* wield a weapon */

		case 'W':
			yrepcount = 0;
			wear();
			return;	/* wear armor	 */

		case 'r':
			yrepcount = 0;
			if (c[BLINDCOUNT]) {
				cursors();
				lprcat("\nYou can't read anything when you're blind!");
			} else if (c[TIMESTOP] == 0)
				readscr();
			return;	/* to read a scroll	 */

		case 'q':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				quaff();
			return;	/* quaff a potion		 */

		case 'd':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				dropobj();
			return;	/* to drop an object	 */

		case 'c':
			yrepcount = 0;
			cast();
			return;	/* cast a spell	 */

		case 'i':
			yrepcount = 0;
			nomove = 1;
			showstr();
			return;	/* status		 */

		case 'e':
			yrepcount = 0;
			if (c[TIMESTOP] == 0)
				eatcookie();
			return;	/* to eat a fortune cookie */

		case 'D':
			yrepcount = 0;
			seemagic(0);
			nomove = 1;
			return;	/* list spells and scrolls */

		case '?':
			yrepcount = 0;
			help();
			nomove = 1;
			return;	/* give the help screen */

		case 'S':
			clear();
			lprcat("Saving . . .");
			lflush();
			savegame(savefilename);
			wizard = 1;
			died(-257);	/* save the game - doesn't return	 */

		case 'Z':
			yrepcount = 0;
			if (c[LEVEL] > 9) {
				oteleport(1);
				return;
			}
			cursors();
			lprcat("\nAs yet, you don't have enough experience to use teleportation");
			return;	/* teleport yourself	 */

		case '^':	/* identify traps */
			flag = yrepcount = 0;
			cursors();
			lprc('\n');
			for (j = playery - 1; j < playery + 2; j++) {
				if (j < 0)
					j = 0;
				if (j >= MAXY)
					break;
				for (i = playerx - 1; i < playerx + 2; i++) {
					if (i < 0)
						i = 0;
					if (i >= MAXX)
						break;
					switch (item[i][j]) {
					case OTRAPDOOR:
					case ODARTRAP:
					case OTRAPARROW:
					case OTELEPORTER:
						lprcat("\nIt's ");
						lprcat(objectname[item[i][j]]);
						flag++;
					};
				}
			}
			if (flag == 0)
				lprcat("\nNo traps are visible");
			return;

#if WIZID
		case '_':	/* this is the fudge player password for
				 * wizard mode */
			yrepcount = 0;
			cursors();
			nomove = 1;
			if (userid != wisid) {
				lprcat("Sorry, you are not empowered to be a wizard.\n");
				scbr();	/* system("stty -echo cbreak"); */
				lflush();
				return;
			}
			if (getpassword() == 0) {
				scbr();	/* system("stty -echo cbreak"); */
				return;
			}
			wizard = 1;
			scbr();	/* system("stty -echo cbreak"); */
			for (i = 0; i < 6; i++)
				c[i] = 70;
			iven[0] = iven[1] = 0;
			take(OPROTRING, 50);
			take(OLANCE, 25);
			c[WIELD] = 1;
			c[LANCEDEATH] = 1;
			c[WEAR] = c[SHIELD] = -1;
			raiseexperience(6000000L);
			c[AWARENESS] += 25000;
			{
				int    i, j;
				for (i = 0; i < MAXY; i++)
					for (j = 0; j < MAXX; j++)
						know[j][i] = 1;
				for (i = 0; i < SPNUM; i++)
					spelknow[i] = 1;
				for (i = 0; i < MAXSCROLL; i++)
					scrollname[i] = scrollhide[i];
				for (i = 0; i < MAXPOTION; i++)
					potionname[i] = potionhide[i];
			}
			for (i = 0; i < MAXSCROLL; i++)
				if (strlen(scrollname[i]) > 2) {	/* no null items */
					item[i][0] = OSCROLL;
					iarg[i][0] = i;
				}
			for (i = MAXX - 1; i > MAXX - 1 - MAXPOTION; i--)
				if (strlen(potionname[i - MAXX + MAXPOTION]) > 2) {	/* no null items */
					item[i][0] = OPOTION;
					iarg[i][0] = i - MAXX + MAXPOTION;
				}
			for (i = 1; i < MAXY; i++) {
				item[0][i] = i;
				iarg[0][i] = 0;
			}
			for (i = MAXY; i < MAXY + MAXX; i++) {
				item[i - MAXY][MAXY - 1] = i;
				iarg[i - MAXY][MAXY - 1] = 0;
			}
			for (i = MAXX + MAXY; i < MAXX + MAXY + MAXY; i++) {
				item[MAXX - 1][i - MAXX - MAXY] = i;
				iarg[MAXX - 1][i - MAXX - MAXY] = 0;
			}
			c[GOLD] += 25000;
			drawscreen();
			return;
#endif

		case 'T':
			yrepcount = 0;
			cursors();
			if (c[SHIELD] != -1) {
				c[SHIELD] = -1;
				lprcat("\nYour shield is off");
				bottomline();
			} else if (c[WEAR] != -1) {
				c[WEAR] = -1;
				lprcat("\nYour armor is off");
				bottomline();
			} else
				lprcat("\nYou aren't wearing anything");
			return;

		case 'g':
			cursors();
			lprintf("\nThe stuff you are carrying presently weighs %ld pounds", (long) packweight());
		case ' ':
			yrepcount = 0;
			nomove = 1;
			return;

		case 'v':
			yrepcount = 0;
			cursors();
			lprintf("\nCaverns of Larn, Version %ld.%ld, Diff=%ld",
				(long) VERSION, (long) SUBVERSION,
				(long) c[HARDGAME]);
			if (wizard)
				lprcat(" Wizard");
			nomove = 1;
			if (cheat)
				lprcat(" Cheater");
			lprcat(copyright);
			return;

		case 'Q':
			yrepcount = 0;
			quit();
			nomove = 1;
			return;	/* quit		 */

		case 'L' - 64:
			yrepcount = 0;
			drawscreen();
			nomove = 1;
			return;	/* look		 */

#if WIZID
#ifdef EXTRA
		case 'A':
			yrepcount = 0;
			nomove = 1;
			if (wizard) {
				diag();
				return;
			}	/* create diagnostic file */
			return;
#endif
#endif
		case 'P':
			cursors();
			if (outstanding_taxes > 0)
				lprintf("\nYou presently owe %ld gp in taxes.",
					(long) outstanding_taxes);
			else
				lprcat("\nYou do not owe any taxes.");
			return;
		};
	}
}
コード例 #14
0
ファイル: main.c プロジェクト: thedukeofzill/fbge
int main(int argc, char *argv[]) {
    wireframe = 1;
    cubecount = 0;
    cubemax = 10000;
    int dir = 1;
    int camdir = 1;
    short gameon = 1;
    int tracker = -100;
    int trackerprime = -tracker;
    int zdist = -50;
    int cubesize = 50;
    int cubeloc = 0;
    int cubelocy = 50;
    double stepcount = 0;
    double turncount = 0;
    camry = 0;
    camrx = 0;
    camrz = 0;
    camx = 0;
    camy = 0;
    camz = -250;
    //world objects 
    cubes = malloc(cubemax*sizeof(shape*));
    for(int i = 0; i < cubemax; i++){
        cubes[i] = malloc(sizeof(shape));
    }
    init_time();
    startengine(); //initialize stuff

    //create floor
    int ctrack = 0;
    for(int x = -1000; x < 1000; x += cubesize){
        for(int z = -1000; z < 1000; z += cubesize){
            short colr;
            if(ctrack%2 == 0) 
                colr = COLOR_BLUE; 
            else 
                colr = COLOR_GREEN;
            *(cubes[cubecount]) = 
                cube(x, 100, z, cubesize, colr);
            cubecount++;ctrack++;
        }
        ctrack++;
    }
    
    
    //place some bridges 
    for(int i = cubesize * 0; i >= 0; i -= cubesize){
        rainbowstairs(tracker - 2*i,cubeloc+cubesize*6,cubesize,cubelocy);
        rainbowstairs(-tracker + 2*i,cubeloc+cubesize*6,cubesize,cubelocy);

        rainbowstairs(tracker - 2*i,cubeloc,cubesize,cubelocy);
        rainbowstairs(-tracker + 2*i,cubeloc,cubesize,cubelocy);
        rainbowstairs(tracker - 2*i,cubeloc-cubesize*6,cubesize,cubelocy);
        rainbowstairs(-tracker + 2*i,cubeloc-cubesize*6,cubesize,cubelocy);
        rainbowstairs(tracker - 2*i,cubeloc+cubesize*12,cubesize,cubelocy);
        rainbowstairs(-tracker + 2*i,cubeloc+cubesize*12,cubesize,cubelocy);
    }
//test
    *(cubes[cubecount]) = cube(0, -50,-100, cubesize,COLOR_RED);
        cubecount++;
    *(cubes[cubecount]) = cube(0, -50,300, cubesize,COLOR_YELLOW);
        cubecount++;
    //pyramid(-500,-25,0,50);
    //variables to track movement
    int rotateleft = -1;
    int rotateright = -1;
    int movingforward = -1;
    int movingbackward = -1;
    double timepassed = 0;

    lasttime = get_time();

    
    if(argc > 1 && strcmp(argv[1],"t") == 0)
        wireframe = 0;

    //main loop
    while(gameon){
        getmaxyx(stdscr,row,col);
        r = row;
        c = col;
        
        for(int i = 0; i < cubecount; i++){
            translatecube(cubes[i]);
        }
        //sort cubes every 10 frames
        if(!(ccount%10))
            qsort((void*)cubes,cubecount,sizeof(shape*),cubesort);
        //draw cubes to buffer
        for(int i = 0; i < cubecount; i++){
            if(argc > 1 && strcmp(argv[1],"1") == 0)
                drawCube(cubes[i],1);
            else
                drawCube(cubes[i],0);
            free(cubes[i]->v2);
        }

        //copy buffer to screen
        drawscreen();

        ccount++;
        refresh();
        move(0,0);
        resetColors();
        resetZBuffer();
        currtime = get_time();
        framerate = (double)(1.0/((currtime - lasttime)*0.000001));
        timepassed = (double)(currtime - lasttime);
        lasttime = currtime;

        //get keyboard input
        ch = getch();
        if(ch != ERR){
            if(ch == KEY_RIGHT || ch =='d'){
                if(rotateright == 1 && turncount > 0){
                    turncount = 0;
                }
                else{
                    rotateleft = 1;
                    turncount = 0.15;
                }
                rotateright = -1;
            }
            else if(ch == KEY_LEFT || ch == 'a'){
                if(rotateleft == 1 && turncount > 0){
                    turncount = 0;
                }
                else{
                    rotateright = 1;
                    turncount = 0.15;
                }
                rotateleft = -1;
            }
            else if(ch == KEY_UP || ch == 'w'){
                if(movingbackward != 1){
                    movingforward = 1;
                    stepcount = 0.15;
                }
                else
                    movingbackward = -1;
            }
            else if(ch == KEY_DOWN || ch == 's'){
                if(movingforward != 1){
                    movingbackward = 1;
                    stepcount = 0.15;
                }
                else
                    movingforward = -1;
            }
            else if(ch == ' '){
                turncount = 0;
            }
            else if(ch == 'q')
                gameon = 0;
        }
        double ff = timepassed/1500;
        int speed = ff;
        if(rotateleft == 1){
            if(turncount > 0){
                camry-=ff/2;
                turncount -= 1/framerate;
            }
        }
        if(rotateright == 1){
            if(turncount > 0){
                camry+=ff/2;
                turncount -= 1/framerate;
            }

        }
        if(movingforward == 1){
            if(stepcount > 0){
                camz += speed*cos(0.01*camry);
                camx -= speed*sin(0.01*camry);
                //camz+=ff/2;
                stepcount -= 1/framerate;
            }
        }
        if(movingbackward == 1){
            if(stepcount > 0){
                camz -= speed*cos(0.01*camry);
                camx += speed*sin(0.01*camry);
                //camz-=ff/2;
                stepcount -= 1/framerate;
            }

        }
        zval = camz + 500;
        dist = -camz;
        //usleep(16000);
    }

    for(int i = 0; i < cubemax; i++){
        free(cubes[i]->v3);
        free(cubes[i]);
    }
    free(cubes);
    killengine();//prevent memory leaks
    return 0;
}
コード例 #15
0
ファイル: graphics.c プロジェクト: sundargates/qed-examples
static void adjustwin (int bnum, void (*drawscreen) (void)) {  
/* The window button was pressed.  Let the user click on the two *
 * diagonally opposed corners, and zoom in on this area.         */

 XEvent report;
 int corner, xold, yold, x[2], y[2];

 corner = 0;
 xold = -1;
 yold = -1;    /* Don't need to init yold, but stops compiler warning. */
 
 while (corner<2) {
    XNextEvent (display, &report);
    switch (report.type) {
    case Expose:
#ifdef VERBOSE 
       printf("Got an expose event.\n");
       printf("Count is: %d.\n",report.xexpose.count);
       printf("Window ID is: %d.\n",report.xexpose.window);
#endif
       if (report.xexpose.count != 0)
           break;
       if (report.xexpose.window == menu)
          drawmenu(); 
       else if (report.xexpose.window == toplevel) {
          drawscreen();
          xold = -1;   /* No rubber band on screen */
       }
       else if (report.xexpose.window == textarea)
          draw_message();
       break;
    case ConfigureNotify:
       top_width = report.xconfigure.width;
       top_height = report.xconfigure.height;
       update_transform();
#ifdef VERBOSE 
       printf("Got a ConfigureNotify.\n");
       printf("New width: %d  New height: %d.\n",top_width,top_height);
#endif
       break;
    case ButtonPress:
#ifdef VERBOSE 
       printf("Got a buttonpress.\n");
       printf("Window ID is: %d.\n",report.xbutton.window);
       printf("Location (%d, %d).\n", report.xbutton.x,
          report.xbutton.y);
#endif
       if (report.xbutton.window != toplevel) break;
       x[corner] = report.xbutton.x;
       y[corner] = report.xbutton.y; 
       if (corner == 0) {
       XSelectInput (display, toplevel, ExposureMask | 
         StructureNotifyMask | ButtonPressMask | PointerMotionMask);
       }
       else {
          update_win(x,y,drawscreen);
       }
       corner++;
       break;
    case MotionNotify:
#ifdef VERBOSE 
       printf("Got a MotionNotify Event.\n");
       printf("x: %d    y: %d\n",report.xmotion.x,report.xmotion.y);
#endif
       if (xold >= 0) {  /* xold set -ve before we draw first box */
          XDrawRectangle(display,toplevel,gcxor,min(x[0],xold),
             min(y[0],yold),abs(x[0]-xold),abs(y[0]-yold));
       }
       /* Don't allow user to window under menu region */
       xold = min(report.xmotion.x,top_width-1-MWIDTH); 
       yold = report.xmotion.y;
       XDrawRectangle(display,toplevel,gcxor,min(x[0],xold),
          min(y[0],yold),abs(x[0]-xold),abs(y[0]-yold));
       break;
    }
 }
 XSelectInput (display, toplevel, ExposureMask | StructureNotifyMask
                | ButtonPressMask); 
}
コード例 #16
0
ファイル: graphics.c プロジェクト: sundargates/qed-examples
void event_loop (void (*act_on_button) (float x, float y), 
    void (*drawscreen) (void)) {

/* The program's main event loop.  Must be passed a user routine        *
 * drawscreen which redraws the screen.  It handles all window resizing *
 * zooming etc. itself.  If the user clicks a button in the graphics    *
 * (toplevel) area, the act_on_button routine passed in is called.      */

 XEvent report;
 int bnum;
 float x, y;

#define OFF 1
#define ON 0

 turn_on_off (ON);
 while (1) {
    XNextEvent (display, &report);
    switch (report.type) {  
    case Expose:
#ifdef VERBOSE 
       printf("Got an expose event.\n");
       printf("Count is: %d.\n",report.xexpose.count);
       printf("Window ID is: %d.\n",report.xexpose.window);
#endif
       if (report.xexpose.count != 0)
           break;
       if (report.xexpose.window == menu)
          drawmenu(); 
       else if (report.xexpose.window == toplevel)
          drawscreen();
       else if (report.xexpose.window == textarea)
          draw_message();
       break;
    case ConfigureNotify:
       top_width = report.xconfigure.width;
       top_height = report.xconfigure.height;
       update_transform();
#ifdef VERBOSE 
       printf("Got a ConfigureNotify.\n");
       printf("New width: %d  New height: %d.\n",top_width,top_height);
#endif
       break; 
    case ButtonPress:
#ifdef VERBOSE 
       printf("Got a buttonpress.\n");
       printf("Window ID is: %d.\n",report.xbutton.window);
#endif
       if (report.xbutton.window == toplevel) {
          x = XTOWORLD(report.xbutton.x);
          y = YTOWORLD(report.xbutton.y); 
          act_on_button (x, y);
       } 
       else {  /* A menu button was pressed. */
          bnum = which_button(report.xbutton.window);
#ifdef VERBOSE 
       printf("Button number is %d\n",bnum);
#endif
          button[bnum].ispressed = 1;
          drawbut(bnum);
          XFlush(display);  /* Flash the button */
          button[bnum].fcn(bnum, drawscreen);
          button[bnum].ispressed = 0;
          drawbut(bnum);
          if (button[bnum].fcn == proceed) {
             turn_on_off(OFF);
             flushinput ();
             return;  /* Rather clumsy way of returning *
                       * control to the simulator       */
          }
       }
       break;
    }
 }
}
コード例 #17
0
ファイル: menu.c プロジェクト: aztli/Traducciones
/* Draws rules menu. */
void
rulesmenu(void)
{
	int wheretogo;
	long tmp;

	do {
		drawscreen();

		mvaddstr( 3, 30, "Typespeed ");
		addstr(TVERSION);

		mvaddstr( 5, 30, _("Current Rule Set:"));

		mvaddstr( 7, 30, _("1. Load Another Rule Set"));
		mvaddstr( 8, 30, _("2. Misses Limit:"));
		mvaddstr( 9, 30, _("3. Word Length:"));
		addstr("    -");
		mvaddstr(10, 30, _("4. Words On Screen:"));
		addstr("    -");
		mvaddstr(11, 30, _("   High Score Enabled:"));
		mvaddstr(12, 30, _("6. Speed Step:"));
		mvaddstr(13, 30, _("7. Speed Range:"));
		addstr("    -");
		mvaddstr(14, 30, _("8. Smoothness:"));
		mvaddstr(15, 30, _("9. Return"));

		xcolor_set(3);
		mvprintw( 5, 31 + strlen(_("Current Rule Set:")), "%s",
		    rules.name);
		mvprintw( 8, 31 + strlen(_("2. Misses Limit:")), "%d",
		    rules.misses);
		mvprintw( 9, 31 + strlen(_("3. Word Length:")), "%2d",
		    rules.minlen);
		mvprintw( 9, 36 + strlen(_("3. Word Length:")), "%2d",
		    rules.maxlen);
		mvprintw(10, 31 + strlen(_("4. Words On Screen:")), "%2d",
		    rules.minwords);
		mvprintw(10, 36 + strlen(_("4. Words On Screen:")), "%2d",
		    rules.maxwords);
		if (rules.hightype)
			mvaddstr(11, 31 + strlen(_("   High Score Enabled:")),
			    _("yes"));
		else
			mvaddstr(11, 31 + strlen(_("   High Score Enabled:")),
			    _("no"));
		mvprintw(12, 31 + strlen(_("6. Speed Step:")), "%3d",
		    rules.step);
		mvprintw(13, 31 + strlen(_("7. Speed Range:")), "%2d",
		    rules.minspeed);
		if (rules.maxspeed)
			mvprintw(13, 36 + strlen(_("7. Speed Range:")), "%2d",
			    rules.maxspeed);
		else
			mvaddstr(13, 37 + strlen(_("7. Speed Range:")),
			    _("0 (unlimited)"));
		if (rules.smooth)
			mvaddstr(14, 31 + strlen(_("8. Smoothness:")),
			    _("yes"));
		else
			mvaddstr(14, 31 + strlen(_("8. Smoothness:")), _("no"));
		xcolor_set(5);
		mvaddstr(17, 30, _("Choose: "));

		switch (wheretogo = getch()) {
		case '1':
			chooseruleset();
			break;
		case '2':
			if ((tmp = getnum(_("Misses Limit:"), 0, 100)))
				rules.misses = tmp;
			break;
		case '3':
			if ((tmp = getnum(_("Min Length:"), 0, 20)))
				rules.minlen = tmp;
			if ((tmp = getnum(_("Max Length:"), 0, 20)))
				rules.maxlen = tmp;
			if (rules.minlen > rules.maxlen)
				rules.maxlen = rules.minlen;
			break;
		case '4':
			if ((tmp = getnum(_("Min Words:"), 0, 23)))
				rules.minwords = tmp;
			if ((tmp = getnum(_("Max Words:"), 0, 23)))
				rules.maxwords = tmp;
			if (rules.minwords > rules.maxwords)
				rules.maxwords = rules.minwords;
			break;
		case '6':
			if ((tmp = getnum(_("Speed Step:"), 0, 1000)))
				rules.step = tmp;
			break;
		case '7':
			if ((tmp = getnum(_("Min Speed:"), 0, 100)))
				rules.minspeed = tmp;
			rules.maxspeed = getnum(_("Max Speed:"), 0, 100);
			if (rules.minspeed > rules.maxspeed)
				rules.maxspeed = 0;
			break;
		case '8':
			rules.smooth = dochange(rules.smooth);
			rules.hightype = 0;
			break;
		default:
			break;
		}
	} while (wheretogo != '9');
}
コード例 #18
0
ファイル: command1.c プロジェクト: albert-wang/OmegaRPG
/* deal with a new player command in dungeon or city mode*/
void p_process(void)
{
    static int searchval=0;

    if (Player.status[BERSERK])
        if (goberserk()) {
            setgamestatus(SKIP_PLAYER);
            drawvision(Player.x,Player.y);
        }
    if (! gamestatusp(SKIP_PLAYER)) {
        if (searchval > 0) {
            searchval--;
            if (searchval == 0) resetgamestatus(FAST_MOVE);
        }
        drawvision(Player.x,Player.y);
        if (! gamestatusp(FAST_MOVE)) {
            searchval = 0;
            Cmd = mgetc();
            clear_if_necessary();
        }
        Command_Duration = 0;
        switch (Cmd) {
        case ' ':
        case 13:
            setgamestatus(SKIP_MONSTERS);
            break; /*no op on space or return*/
        case 6:
            abortshadowform();
            break; /* ^f */
        case 7:
            wizard();
            break; /* ^g */
        case 4:
            player_dump();
            break; /* ^d */
        case 9:
            display_pack();
            morewait();
            xredraw();
            break; /* ^i */
        case 11:
            if (gamestatusp(CHEATED)) frobgamestatus();
            break;
        case 12:
            xredraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^l */
#if !defined(WIN32)
        case 16:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^p */
#else
        case 15:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^o */
#endif
        case 18:
            redraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^r */
        case 23:
            if (gamestatusp(CHEATED)) drawscreen();
            break; /* ^w */
        case 24: /* ^x */
            if (gamestatusp(CHEATED) ||
                    Player.rank[ADEPT])
                wish(1);
            Command_Duration = 5;
            break;
        case 'a':
            zapwand();
            Command_Duration = Player.speed*8/5;
            break;
        case 'c':
            closedoor();
            Command_Duration = Player.speed*2/5;
            break;
        case 'd':
            drop();
            Command_Duration = Player.speed*5/5;
            break;
        case 'e':
            eat();
            Command_Duration = 30;
            break;
        case 'f':
            fire();
            Command_Duration = Player.speed*5/5;
            break;
        case 'g':
            pickup();
            Command_Duration = Player.speed*10/5;
            break;
        case 'i':
            do_inventory_control();
            break;
        case 'm':
            magic();
            Command_Duration = 12;
            break;
        case 'o':
            opendoor();
            Command_Duration = Player.speed*5/5;
            break;
        case 'p':
            pickpocket();
            Command_Duration = Player.speed*20/5;
            break;
        case 'q':
            quaff();
            Command_Duration = 10;
            break;
        case 'r':
            peruse();
            Command_Duration = 20;
            break;
        case 's':
            search(&searchval);
            Command_Duration = 20;
            break;
        case 't':
            talk();
            Command_Duration = 10;
            break;
        case 'v':
            vault();
            Command_Duration = Player.speed*10/5;
            break;
        case 'x':
            examine();
            Command_Duration = 1;
            break;
        case 'z':
            bash_location();
            Command_Duration = Player.speed*10/5;
            break;
        case 'A':
            activate();
            Command_Duration = 10;
            break;
        case 'C':
            callitem();
            break;
        case 'D':
            disarm();
            Command_Duration = 30;
            break;
        case 'E':
            dismount_steed();
            Command_Duration = Player.speed*10/5;
            break;
        case 'F':
            tacoptions();
            break;
        case 'G':
            give();
            Command_Duration = 10;
            break;
        case 'I':
            if (! optionp(TOPINV)) top_inventory_control();
            else {
                display_possessions();
                inventory_control();
            }
            break;
        case 'M':
            city_move();
            Command_Duration = 10;
            break;
        case 'O':
            setoptions();
#if defined(WIN32)
            show_screen();
            xredraw();
#endif
            break;
        case 'P':
            show_license();
            break; /* actually show_license is in file.c */
        case 'Q':
            quit();
            break;
        case 'R':
            rename_player();
            break;
        case 'S':
            save(FALSE);
            break;
        case 'T':
            tunnel();
            Command_Duration =  Player.speed*30/5;
            break;
        case 'V':
            version();
            break;
        case 'Z':
            bash_item();
            Command_Duration = Player.speed*10/5;
            break;
        case '.':
            rest();
            Command_Duration = 10;
            break;
        case ',':
            Command_Duration = 10;
            nap();
            break;
        case '>':
            downstairs();
            break;
        case '<':
            upstairs();
            break;
        case '@':
            p_movefunction(Level->site[Player.x][Player.y].p_locf);
            Command_Duration = 5;
            break;
        case '#':
            if (gamestatusp(CHEATED)) editstats();
            break; /* RAC - char editor */
        case '/':
            charid();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '?':
            help();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '4':
        case 'h':
            moveplayer(-1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '2':
        case 'j':
            moveplayer(0,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '8':
        case 'k':
            moveplayer(0,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '6':
        case 'l':
            moveplayer(1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '1':
        case 'b':
            moveplayer(-1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '3':
        case 'n':
            moveplayer(1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '7':
        case 'y':
            moveplayer(-1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '9':
        case 'u':
            moveplayer(1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '5':
            setgamestatus(SKIP_MONSTERS); /* don't do anything; a dummy turn */
            Cmd = mgetc();
            while ((Cmd != ESCAPE) &&
                    ((Cmd < '1') || (Cmd > '9') || (Cmd=='5'))) {
                print3("Run in keypad direction [ESCAPE to abort]: ");
                Cmd = mgetc();
            }
            if (Cmd != ESCAPE) 
                setgamestatus(FAST_MOVE);
            else
                clearmsg3();
            break;
        case 'H':
            setgamestatus(FAST_MOVE);
            Cmd = 'h';
            moveplayer(-1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'J':
            setgamestatus(FAST_MOVE);
            Cmd = 'j';
            moveplayer(0,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'K':
            setgamestatus(FAST_MOVE);
            Cmd = 'k';
            moveplayer(0,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'L':
            setgamestatus(FAST_MOVE);
            Cmd = 'l';
            moveplayer(1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'B':
            setgamestatus(FAST_MOVE);
            Cmd = 'b';
            moveplayer(-1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'N':
            setgamestatus(FAST_MOVE);
            Cmd = 'n';
            moveplayer(1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'Y':
            setgamestatus(FAST_MOVE);
            Cmd = 'y';
            moveplayer(-1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'U':
            setgamestatus(FAST_MOVE);
            Cmd = 'u';
            moveplayer(1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        default:
            commanderror();
            setgamestatus(SKIP_MONSTERS);
            break;
        }
    }
    if (Current_Environment != E_COUNTRYSIDE) roomcheck();
    screencheck(Player.x,Player.y);
}
コード例 #19
0
ファイル: main.c プロジェクト: LibreGames/digger
void game(void)
{
  int16_t t,c,i;
  bool flashplayer=false;
  if (gauntlet) {
    cgtime=gtime*1193181l;
    timeout=false;
  }
  initlives();
  gamedat[0].level=startlev;
  if (nplayers==2)
    gamedat[1].level=startlev;
  alldead=false;
  ddap->gclear();
  curplayer=0;
  initlevel();
  curplayer=1;
  initlevel();
  zeroscores();
  bonusvisible=true;
  if (nplayers==2)
    flashplayer=true;
  curplayer=0;
  while (getalllives()!=0 && !escape && !timeout) {
    while (!alldead && !escape && !timeout) {
      initmbspr();

      if (playing)
        randv=playgetrand();
      else
        randv=getlrt();
#ifdef INTDRF
      fprintf(info,"%lu\n",randv);
      frame=0;
#endif
      recputrand(randv);
      if (levnotdrawn) {
        levnotdrawn=false;
        drawscreen(ddap);
        if (flashplayer) {
          flashplayer=false;
          strcpy(pldispbuf,"PLAYER ");
          if (curplayer==0)
            strcat(pldispbuf,"1");
          else
            strcat(pldispbuf,"2");
          cleartopline();
          for (t=0;t<15;t++)
            for (c=1;c<=3;c++) {
              outtext(ddap, pldispbuf,108,0,c);
              writecurscore(ddap, c);
              newframe();
              if (escape)
                return;
            }
          drawscores(ddap);
          for (i=0;i<diggers;i++)
            addscore(ddap, i,0);
        }
      }
      else
        initchars();
      outtext(ddap, "        ",108,0,3);
      initscores(ddap);
      drawlives(ddap);
      music(1);

      flushkeybuf();
      for (i=0;i<diggers;i++)
        readdirect(i);
      while (!alldead && !gamedat[curplayer].levdone && !escape && !timeout) {
        penalty=0;
        dodigger(ddap);
        domonsters(ddap);
        dobags(ddap);
        if (penalty>8)
          incmont(penalty-8);
        testpause();
        checklevdone();
      }
      erasediggers();
      musicoff();
      t=20;
      while ((getnmovingbags()!=0 || t!=0) && !escape && !timeout) {
        if (t!=0)
          t--;
        penalty=0;
        dobags(ddap);
        dodigger(ddap);
        domonsters(ddap);
        if (penalty<8)
          t=0;
      }
      soundstop();
      for (i=0;i<diggers;i++)
        killfire(i);
      erasebonus(ddap);
      cleanupbags();
      savefield();
      erasemonsters();
      recputeol();
      if (playing)
        playskipeol();
      if (escape)
        recputeog();
      if (gamedat[curplayer].levdone)
        soundlevdone();
      if (countem()==0 || gamedat[curplayer].levdone) {
#ifdef INTDRF
        fprintf(info,"%i\n",frame);
#endif
        for (i=curplayer;i<diggers+curplayer;i++)
          if (getlives(i)>0 && !digalive(i))
            declife(i);
        drawlives(ddap);
        gamedat[curplayer].level++;
        if (gamedat[curplayer].level>1000)
          gamedat[curplayer].level=1000;
        initlevel();
      }
      else
        if (alldead) {
#ifdef INTDRF
          fprintf(info,"%i\n",frame);
#endif
          for (i=curplayer;i<curplayer+diggers;i++)
            if (getlives(i)>0)
              declife(i);
          drawlives(ddap);
        }
      if ((alldead && getalllives()==0 && !gauntlet && !escape) || timeout)
        endofgame(ddap);
    }
    alldead=false;
    if (nplayers==2 && getlives(1-curplayer)!=0) {
      curplayer=1-curplayer;
      flashplayer=levnotdrawn=true;
    }
  }
#ifdef INTDRF
  fprintf(info,"-1\n%lu\n%i",getscore0(),gamedat[0].level);
#endif
}
コード例 #20
0
ファイル: yaed.c プロジェクト: BackupTheBerlios/yaed
int main(int argc, char **argv)
{
	struct termios term, term_saved;
	file_t *file;
	
	if(argc > 2)
	{
		printf("ERROR: Invalid arguments!\n");
		return 1;
	}
	
	newfile();
	
	file = files[0];
	
	if(argc == 2)
	{
		/* filename given */
		strcpy(file->filename, argv[1]);
		loadfile(file, argv[1]);
	}
	else
		file->filename[0] = 0;
	
	file->saved = 1;
	
	current = 0;
	
	/* make sure we got something */
	if(!file->line_count)
		insertline(file, 0);
	
	file->cursor_x = 0;
	file->cursor_y = 0;
	
	tcgetattr(0, &term_saved);
	
	/* initialize curses */
	screen = initscr();
	cbreak();
	nonl();
	noecho();
	
	keypad(screen, TRUE);
	
	/* modify terminal settings */
	tcgetattr(0, &term);
	term.c_lflag &= ~(IEXTEN | ISIG);
	term.c_iflag &= ~IXON;
	term.c_oflag &= ~OPOST;	
	tcsetattr(0, TCSANOW, &term);
	
	/* setup colors */
	start_color();
	init_pair(1, COLOR_YELLOW, COLOR_BLACK);
	init_pair(2, COLOR_WHITE, COLOR_BLACK);
	init_pair(3, COLOR_WHITE, COLOR_BLUE);
	init_pair(4, COLOR_WHITE, COLOR_BLUE);
	init_pair(5, COLOR_GREEN, COLOR_BLACK);
	init_pair(6, COLOR_BLUE, COLOR_BLACK);
	init_pair(7, COLOR_BLACK, COLOR_BLACK);
	attron(COLOR_PAIR(2));
	
	getmaxyx(screen, h, w);
	
	drawmenu();	
	drawscreen();
	drawpos();
	
	setcursor();
	refresh();
	
	/* main loop */
	while(!editor_loop());
	
	endwin();
	
	/* revert terminal settings */
	tcsetattr(0, TCSANOW, &term_saved);
	
	return 0;
}
コード例 #21
0
ファイル: draw.c プロジェクト: BackupTheBerlios/pvpr
static void highlight_blocks (float x, float y) {

/* This routine is called when the user clicks in the graphics area. *
 * It determines if a clb was clicked on.  If one was, it is         *
 * highlighted in green, it's fanin nets and clbs are highlighted in *
 * blue and it's fanout is highlighted in red.  If no clb was        *
 * clicked on (user clicked on white space) any old highlighting is  *
 * removed.  Note that even though global nets are not drawn, their  *
 * fanins and fanouts are highlighted when you click on a block      *
 * attached to them.                                                 */

 int i, j, k, hit, bnum, ipin, netnum, fanblk;
 int class;
 float io_step;
 char msg[BUFSIZE];

 io_step = clb_width/io_rat;
 deselect_all ();

 hit = 0;
 for (i=0;i<=nx+1;i++) {
    if (x <= x_clb_left[i]+clb_width) {
       if (x >= x_clb_left[i]) 
          hit = 1;
       break;
    }
 }
 if (!hit) {
    update_message (default_message);
    drawscreen();
    return;
 }

 hit = 0;
 for (j=0;j<=ny+1;j++) {
    if (y <= y_clb_bottom[j]+clb_width) {
       if (y >= y_clb_bottom[j])
          hit = 1;
       break;
    }
 }
 if (!hit) {
    update_message (default_message); 
    drawscreen();
    return;
 }

/* The user selected the clb at location (i,j). */
 if (clb[i][j].type == CLB) {
    if (clb[i][j].occ == 0) {
       update_message (default_message); 
       drawscreen ();
       return;
    }
    bnum = clb[i][j].u.block;
 }
 else {   /* IO block clb */
    if (i == 0 || i == nx+1)      /* Vertical columns of IOs */
       k = (int) ((y - y_clb_bottom[j]) / io_step);
    else 
       k = (int) ((x - x_clb_left[i]) / io_step);

    if (k >= clb[i][j].occ) {   /* Empty spot */
       update_message (default_message); 
       drawscreen();
       return;
    }
    bnum = clb[i][j].u.io_blocks[k];
 }

/* Highlight fanin and fanout. */

 if (block[bnum].type == OUTPAD) {
    netnum = block[bnum].nets[0];    /* Only net. */
    net_color[netnum] = BLUE;        /* Outpad drives nothing */
    fanblk = net[netnum].blocks[0];    /* Net driver */
    block_color[fanblk] = BLUE;
 }

 else if (block[bnum].type == INPAD) {
    netnum = block[bnum].nets[0];    /* Only net. */
    net_color[netnum] = RED;         /* Driven by INPAD */

/* Highlight fanout blocks in RED */

    for (ipin=1;ipin<net[netnum].num_pins;ipin++) { 
       fanblk = net[netnum].blocks[ipin];
       block_color[fanblk] = RED;
    }
 }

 else {       /* CLB block. */
    for (k=0;k<pins_per_clb;k++) {     /* Each pin on a CLB */
       netnum = block[bnum].nets[k];

       if (netnum == OPEN)
          continue;

       class = clb_pin_class[k];

       if (class_inf[class].type == DRIVER) {  /* Fanout */
          net_color[netnum] = RED;
          for (ipin=1;ipin<net[netnum].num_pins;ipin++) { 
             fanblk = net[netnum].blocks[ipin];
             block_color[fanblk] = RED;
          }
       }

       else {         /* This net is fanin to the block. */
          net_color[netnum] = BLUE;
          fanblk = net[netnum].blocks[0];
          block_color[fanblk] = BLUE;
       }
    }
 }