コード例 #1
0
ファイル: etch.c プロジェクト: andrewca/ECE497
void main( void ){
  int inKey;
  struct curCoor map;
  map.X = BOARD_WIDTH/2;
  map.Y = BOARD_HEIGHT/2;
  

  initscr();

  while(1){    
    inKey = getcha();
    if ( inKey == 0x1b) { 
      inKey = getcha();
      if (inKey == 0x5b){ 
	inKey = getcha();
      }
    } else { 
	if (inKey == 'c'){
	  erase();
	}

    }
    
   // Up-Arrow 
    if ( inKey == 0x41 ){
      if (map.Y > 0 ){
        map.Y -= 1;
      } else {
        continue;
      }
    }

   // Down-Arrow
    if ( inKey == 0x42 ){
      if (map.Y < (BOARD_HEIGHT-1) ){
        map.Y += 1;
      } else {
        continue;
      }
    }

   // Right-Arrow 
    if ( inKey == 0x43 ){
      if (map.X < (BOARD_WIDTH-1) ){
        map.X += 1;
      } else {
        continue;
      }
    }

   // Left-Arrow 
    if ( inKey == 0x44 ){
      if (map.X > 0 ){
        map.X -= 1;
      } else {
        continue;
      }
    }
  etchBoard[map.Y][map.X] = 1;

  mvaddch(map.Y, map.X, '1');

  refresh();

  }



}
コード例 #2
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_blanko(int y, int x){
	attron(COLOR_PAIR(6));
	mvaddch(y, x, ' ');
	matrix[y - y1b][x - x1b] = ' ';
}
コード例 #3
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_head(int y, int x)
{
	attron(COLOR_PAIR(6));
	mvaddch(y, x, ACS_BOARD | A_BOLD);
	matrix[y - y1b][x - x1b] = 'h';
}
コード例 #4
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_grass(int y, int x){
	attron(COLOR_PAIR(2));
	mvaddch(y, x, ACS_BOARD);
	matrix[y - y1b][x - x1b] = 'g';
}
コード例 #5
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_water(int y, int x){
	attron(COLOR_PAIR(12));
	mvaddch(y, x, ACS_BOARD);
	matrix[y - y1b][x - x1b] = 'w';
}
コード例 #6
0
ファイル: Ghost.cpp プロジェクト: Wajihulhassan/Pacman
void Ghost::moveG(bool bonus, bool bonusEnding, int pacY, int pacX ){
    if (dir=='R'){
	    if(!collisionM( pacX, pacY )){

                mvaddch( y, x, ' ' );

                foodPutter(y,x);

                ++x;

             // The if, else if, and else determine the color of the ghosts.
		 	 if(bonus)
                {

                mvaddch( y, x, newGhost );

                ghostEaten = true;

                }// if(bonus)

            else if(bonusEnding)
                {

                mvaddch( y, x, cautionGhost );

                ghostEaten = true;

                }// else if(bonusEnding)

             else
                {

                mvaddch( y, x, icon );

                ghostEaten = false;

                }// else of if(bonus)

        checkY = pacX;

        checkX = pacY;

		}
	  refresh();
	  }
	else if(dir=='L')
	 	{
		if(!collisionM( pacX, pacY )){

            mvaddch( y, x, ' ' );

            foodPutter(y,x);

            --x;

		 	 if(bonus)
                {

                mvaddch( y, x, newGhost );

                ghostEaten = true;

                }// if(bonus)

             else if(bonusEnding)
                {

                mvaddch( y, x, cautionGhost );

                ghostEaten = true;

                }// else if(bonusEnding)

             else
                {

                mvaddch( y, x,icon );

                ghostEaten = false;

                }// else of if(bonus)

        checkY = pacX;

        checkX = pacY;

		}
		refresh();
	 }
	else if(dir == 'U')
	    {
		if(!collisionM( pacX, pacY )){

            mvaddch( y, x, ' ' );

            foodPutter(y,x);

		  	 --y;

		 	 if(bonus)
                {

                mvaddch( y, x, newGhost );

                ghostEaten = true;

                }// if(bonus)

             else if(bonusEnding)
                {

                mvaddch( y, x, cautionGhost );

                ghostEaten = true;

                }// else if(bonusEnding)

             else
                {

                mvaddch( y, x, icon );

                ghostEaten = false;

                }// else of if(bonus)

            checkY = pacX;

            checkX = pacY;

		    }
	      refresh();
	    }
	  else if (dir =='D')
	     {
	       if(!collisionM( pacX, pacY )){

            mvaddch( y, x, ' ' );

            foodPutter(y,x);

		 	 ++y;
		 	 //attron(COLOR_PAIR(colorswitch));

		 	 if(bonus)
                {

                mvaddch( y, x, newGhost );

                ghostEaten = true;

                }// if(bonus)

             else if(bonusEnding)
                {

                mvaddch( y, x, cautionGhost );

                ghostEaten = true;

                }// else if(bonusEnding)

             else
                {

                mvaddch( y, x, icon );

                ghostEaten = false;

                }// else of if(bonus)

		 	 //attroff(COLOR_PAIR(colorswitch));


             checkY = pacX;

             checkX = pacY;

		 	 }
	      refresh();
	     }
	    int  t=rand()%20;
	     if (t==0){
	       dir = arrdirm[(rand()%4)];
	    }

}
コード例 #7
0
ファイル: editor.c プロジェクト: Bencepapa/CymonsGames
void EditorAction()
{
	unsigned char tile, previous;
	if (editing_terrain)
	{
		if (cursor_y<MAP_SIZE_Y)
		{
			terrain[cursor_y][cursor_x]=current_terrain;
			attrset(COLOR_PAIR(terrain_prop[current_terrain].color));
			mvaddch(cursor_y,cursor_x,terrain_prop[current_terrain].tile);
			refresh();
		}
		else if (cursor_y==22 && cursor_x<TERRAIN_MAX)
		{
			current_terrain=cursor_x;
			ShowEditorWindow();
		}
	}
	else
	{
		if (cursor_y<MAP_SIZE_Y)
		{
			previous=unit_placement[cursor_y][cursor_x];
			if (previous>='a' && previous<='z')
				++blue_units_left;
			else if (previous>='A' && previous<='Z')
				++red_units_left;

			if (current_unit==UNIT_TYPE_MAX) // removing
			{
				unit_placement[cursor_y][cursor_x]='.';
				ShowEditorMap();
				ShowEditorWindow();
				return;
			}
			else
			{
				if (editing_blue)
				{
					if (blue_units_left==0)
						return;
					else
						--blue_units_left;
				}
				else
				{
					if (red_units_left==0)
						return;
					else
						--red_units_left;
				}
			}

			tile = unit_prop[current_unit].tile - (editing_blue?0:0x20);
			unit_placement[cursor_y][cursor_x]=tile;
			if (editing_blue)
				attrset(COLOR_PAIR(COLOR_WHITE+COLOR_BLUE*8)|A_BOLD);
			else
				attrset(COLOR_PAIR(COLOR_WHITE+COLOR_RED*8)|A_BOLD);
			mvaddch(cursor_y,cursor_x,unit_prop[current_unit].tile);
			ShowEditorWindow();
		}
		else if (cursor_y==22)
		{
			if (cursor_x<UNIT_TYPE_MAX)
			{
				current_unit=cursor_x;
				ShowEditorWindow();
			}
			else if (cursor_x==UNIT_TYPE_MAX)
			{
				current_unit=UNIT_TYPE_MAX;
				ShowEditorWindow();
			}
			else if (cursor_x==UNIT_TYPE_MAX+1)
			{
				editing_blue=!editing_blue;
				ShowEditorWindow();
			}
		}

	}
}
コード例 #8
0
ファイル: output.cpp プロジェクト: Devanon/Cataclysm-DDA
void mvputch(int y, int x, nc_color FG, long ch)
{
    attron(FG);
    mvaddch(y, x, ch);
    attroff(FG);
}
コード例 #9
0
ファイル: scrolls.c プロジェクト: ajpaulson/srogue11
/*
 * read_scroll:
 *	Let the hero read a scroll
 */
int read_scroll()
{
	struct object *obj;
	struct linked_list *item;
	int i, j, wh;
	unsigned long ch, nch;
	struct room *rp;
	struct linked_list *titem;
	char buf[LINLEN];
	bool bless, curse;

	if ((item = get_item("read", SCROLL)) == NULL)
		return 0;
	obj = OBJPTR(item);
	if (obj->o_type != SCROLL) {
		msg("Nothing to read.");
		after = FALSE;
		return 0;
	}
	msg("As you read the scroll, it vanishes.");
	wh = obj->o_which;
	bless = o_on(obj, ISBLESS);
	curse = o_on(obj, ISCURSED);
	del_pack(item);		/* Get rid of the thing */

	/*
	 * Calculate the effect it has on the hero
	 */
	switch(wh) {
	case S_KNOWALL:
		if (!curse) {
			idenpack();				/* identify all the pack */
			msg("You feel more knowledgable.");
			chg_abil(WIS,1,TRUE);
			s_know[S_KNOWALL] = TRUE;
		}
	when S_CONFUSE:
		if (!curse) {
			/*
			 * Scroll of monster confusion.  Give him that power.
			 */
			msg("Your hands begin to glow red.");
			player.t_flags |= CANHUH;
			s_know[S_CONFUSE] = TRUE;
		}
	when S_LIGHT:
		rp = player.t_room;
		if (!curse) {
			if (rp == NULL) {
				s_know[S_LIGHT] = TRUE;
				msg("The corridor glows and then fades.");
			}
			else {
				if (rf_on(rp,ISDARK)) {
					s_know[S_LIGHT] = TRUE;
					msg("The room is lit.");
					rp->r_flags &= ~ISDARK;
				}
				light(&hero);
				mvwaddch(cw, hero.y, hero.x, PLAYER);
			}
		}
	when S_ARMOR:
		if (!curse) {
			if (cur_armor != NULL && o_off(cur_armor,ISPROT)) {
				s_know[S_ARMOR] = TRUE;
				msg("Your armor glows faintly for a moment.");
				if (o_on(cur_armor,ISCURSED))
					cur_armor->o_ac = armors[cur_armor->o_which].a_class;
				else
					cur_armor->o_ac--;
				resoflg(cur_armor,ISCURSED);
			}
		}
	when S_HOLD:
		if (!curse) {
			/*
			 * Hold monster scroll.  Stop all monsters within 3 spaces
			 * from chasing after the hero.
			 */
			int x,y;
			struct linked_list *mon;

			for (x = hero.x - 3; x <= hero.x + 3; x++) {
				for (y = hero.y - 3; y <= hero.y + 3; y++) {
					if (y > 0 && x > 0 && isalpha(mvwinch(mw, y, x))) {
						if ((mon = find_mons(y, x)) != NULL) {
							struct thing *th;

							th = THINGPTR(mon);
							th->t_flags &= ~ISRUN;
							th->t_flags |= ISHELD;
							th->t_flags |= ISSTUCK;
						}
					}
				}
			}
		}
	when S_SLEEP:
		/*
		 * Scroll which makes you fall asleep
		 */
		if (!bless) {
			s_know[S_SLEEP] = TRUE;
			msg("You fall asleep.");
			player.t_nocmd += 4 + rnd(SLEEPTIME);
		}
	when S_CREATE:
		if (!bless) {
			if (makemons(mtlev[rnd(levcount)]->m_show))
				s_know[S_CREATE] = TRUE;
			else
				msg("You hear a faint cry of anguish in the distance.");
		}
	when S_IDENT:
		if (!curse) {
			msg("This scroll is an identify scroll");
			s_know[S_IDENT] = TRUE;
			whatis(NULL);
		}
	when S_MAP:
		if (curse)
			break;
		s_know[S_MAP] = TRUE;
		addmsg("Oh, now this scroll has a ");
		if (rnd(100) < 10 || bless) {
			addmsg("very detailed map on it.");
			endmsg();
			displevl();
		}
		else {
			addmsg("map on it.");
			endmsg();
			overwrite(stdscr, hw);
			for (i = 1; i < LINES - 2; i++) {
				for (j = 0; j < COLS; j++) {
					switch (nch = ch = mvwinch(hw, i, j)) {
						case SECRETDOOR:
							nch = DOOR;
							mvaddch(i, j, nch);
						case '-':
						case '|':
						case DOOR:
						case PASSAGE:
						case ' ':
						case STAIRS:
							if (mvwinch(mw, i, j) != ' ') {
								struct thing *it;
								struct linked_list *blah;

								blah = find_mons(i, j);
								if (blah != NULL) {
									it = THINGPTR(blah);
									if (it->t_oldch == ' ')
										it->t_oldch = nch;
								}
							}
							break;
						default:
							nch = ' ';
					}
					if (nch != ch)
						waddch(hw, nch);
				}
			}
			overlay(cw, hw);
			overwrite(hw, cw);
		}
	when S_GFIND:
		if (!curse) {
			int gtotal = 0;
			struct room *rp;

			wclear(hw);
			for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) {
				gtotal += rp->r_goldval;
				if (rp->r_goldval != 0 &&
				  mvinch(rp->r_gold.y,rp->r_gold.x) == GOLD)
					mvwaddch(hw,rp->r_gold.y,rp->r_gold.x,GOLD);
			}
			if (gtotal) {
				s_know[S_GFIND] = TRUE;
				msg("You begin to feel greedy and sense gold.");
				overlay(hw,cw);
			}
			else
				msg("You begin to feel a pull downward.");
		}
	when S_TELEP:
		if (!curse) {
			int rm;
			struct room *cur_room;

			cur_room = player.t_room;
			rm = teleport(rndspot, &player);
			if (cur_room != &rooms[rm])
				s_know[S_TELEP] = TRUE;
		}
	when S_ENCH:
		if (!curse) {
			if (cur_weapon == NULL || (cur_weapon != NULL &&
			  (o_on(cur_weapon,ISPROT) || cur_weapon->o_type != WEAPON)))
				msg("You feel a strange sense of loss.");
			else {
				s_know[S_ENCH] = TRUE;
				if (o_on(cur_weapon,ISCURSED)) {
					resoflg(cur_weapon,ISCURSED);
					cur_weapon->o_hplus = rnd(2);
					cur_weapon->o_dplus = rnd(2);
				}
				else {		/* weapon was not cursed here */
					if (rnd(100) < 50)
						cur_weapon->o_hplus += 1;
					else
						cur_weapon->o_dplus += 1;
				}
				setoflg(cur_weapon, ISKNOW);
				msg("Your %s glows blue for a moment.",
				  w_magic[cur_weapon->o_which].mi_name);
			}
		}
	when S_SCARE:
		/*
		 * A monster will refuse to step on a scare monster scroll
		 * if it is dropped.  Thus reading it is a mistake and produces
		 * laughter at the poor rogue's boo boo.
		 */
		msg("You hear maniacal laughter in the distance.");
	when S_REMOVE:
		if (!curse) {
			if (cur_armor != NULL && o_off(cur_armor,ISPROT))
				resoflg(cur_armor,ISCURSED);
			if (cur_weapon != NULL && o_off(cur_weapon,ISPROT))
				resoflg(cur_weapon,ISCURSED);
			if (cur_ring[LEFT]!=NULL && o_off(cur_ring[LEFT],ISPROT))
				resoflg(cur_ring[LEFT],ISCURSED);
			if (cur_ring[RIGHT]!=NULL && o_off(cur_ring[RIGHT],ISPROT))
				resoflg(cur_ring[RIGHT],ISCURSED);
			msg("You feel as if somebody is watching over you.");
			s_know[S_REMOVE] = TRUE;
		}
	when S_AGGR:
		if (!bless) {
			if (mlist != NULL) {
				aggravate();
				msg("You hear a high pitched humming noise.");
				s_know[S_AGGR] = TRUE;
			}
		}
	when S_NOP:
		msg("This scroll seems to be blank.");
	when S_GENOCIDE:
		if (!curse) {
			msg("You have been granted the boon of genocide.");
			genocide();
			s_know[S_GENOCIDE] = TRUE;
		}
	when S_DCURSE:
		if (!bless) {
			struct linked_list *ll;
			struct object *lb;

			msg("Your pack shudders.");
			for (ll = pack ; ll != NULL ; ll = next(ll)) {
				lb = OBJPTR(ll);
				if (o_off(lb,ISPROT)) {
					resoflg(lb, ISBLESS);
					setoflg(lb, ISCURSED);
				}
			}
		}
	when S_DLEVEL:
		if (!bless) {
			int much = rnd(9) - 4;

			if (much != 0) {
				level += much;
				if (level < 1)
					level = 1;
				mpos = 0;
				new_level(NORMLEV);		/* change levels */
				msg("You are whisked away to another region.");
				s_know[S_DLEVEL] = TRUE;
			}
		}
	when S_PROTECT:
		if (!curse) {
			struct linked_list *ll;
			struct object *lb;

			msg("You are granted the power of protection.");
			if ((ll = get_item("protect",0)) != NULL) {
				lb = OBJPTR(ll);
				setoflg(lb,ISPROT);
				mpos = 0;
				msg("Protected %s.",inv_name(lb,TRUE));
			}
			s_know[S_PROTECT] = TRUE;
		}
	when S_ALLENCH:
		if (!curse) {
			struct linked_list *ll;
			struct object *lb;
			int howmuch, ac, good;

			msg("You are granted the power of enchantment.");
			good = TRUE;
			if ((ll = get_item("enchant",0)) != NULL) {
				lb = OBJPTR(ll);
				resoflg(lb,ISCURSED);
				resoflg(lb,ISPROT);
				howmuch = rnd(3) + 1;
				switch(lb->o_type) {
					case RING:
						if (lb->o_ac < 0)
							lb->o_ac = 0;
						lb->o_ac += howmuch;
					when ARMOR:
						ac = armors[lb->o_which].a_class;
						if (lb->o_ac > ac)
							lb->o_ac = ac;
						lb->o_ac -= howmuch;
					when STICK:
						lb->o_charges += howmuch + 10;
					when WEAPON:
						if (lb->o_dplus < 0)
							lb->o_dplus = 0;
						if (lb->o_hplus < 0)
							lb->o_hplus = 0;
						lb->o_hplus += howmuch;
						lb->o_dplus += howmuch;
					otherwise:
						msg("You are injured as the scroll flashes & bursts into flames !!!");
						chg_hpt(-roll(6,6),FALSE,K_SCROLL);
						good = FALSE;
				}
				if (good) {
					mpos = 0;
					msg("Enchanted %s.",inv_name(lb,TRUE));
				}
			}
			s_know[S_ALLENCH] = TRUE;
		}
	when S_BLESS:
		if (!curse) {
			struct linked_list *ll;
			struct object *lb;

			msg("Your pack glistens brightly.");
			for (ll = pack ; ll != NULL ; ll = next(ll)) {
				whatis(ll);
				lb = OBJPTR(ll);
				resoflg(lb,ISCURSED);
				setoflg(lb,ISBLESS);
			}
		}
	when S_MAKEIT:
		if (!curse) {
			msg("You have been endowed with the power of creation.");
			s_know[S_MAKEIT] = TRUE;
			create_obj(TRUE);
		}
	when S_BAN: {
		int howdeep;
		char *ptr;

		if (bless) {
			if (level > 6) {
				howdeep = 1 + rnd(5);
				ptr = "elevated to the upper";
			}
			else {
				howdeep = -1;
				bless = FALSE;
			}
		}
		else {
			howdeep = level + 10 + rnd(20) + (curse * 20);
			ptr = "banished to the lower";
		}
		if ((!bless && level < howdeep) || bless) {
			level = howdeep;
			new_level(NORMLEV);
			mpos = 0;
			msg("You are %s regions.", ptr);
			s_know[S_BAN] = TRUE;
		}
	}
	when S_CWAND:
		if (!curse) {
			struct linked_list *ll;
			struct object *lb;
			bool wands = FALSE;

			for (ll = pack ; ll != NULL ; ll = next(ll)) {
				lb = OBJPTR(ll);
				if (lb->o_type == STICK) {
					whatis(ll);
					setoflg(lb, ISKNOW);
					resoflg(lb, ISCURSED);
					lb->o_charges += rnd(11) + 5;
					wands = TRUE;
				}
			}
			if (wands) {
				msg("Your sticks gleam.");
				s_know[wh] = TRUE;
			}
		}
	when S_LOCTRAP: {
		struct trap *trp;

		if (ntraps > 0) {
			for (trp = &traps[0]; trp < &traps[ntraps]; trp++)
				trp->tr_flags |= ISFOUND;
			look(FALSE);
			msg("You now recognize pitfalls.");
			s_know[S_LOCTRAP] = TRUE;
		}
	}
	otherwise:
		msg("What a puzzling scroll!");
		return 0;
	}
コード例 #10
0
ファイル: joytest.c プロジェクト: bsdelf/bsd-hdaps
int main()
{

	int pos_x, pos_y, rest_x, rest_y, old_pos_x, old_pos_y, dx, dy;
	int xmin, xmax, ymin, ymax, xcorr, ycorr;
	int char_x, char_y, delchar_x, delchar_y;
	struct joystick joydata = { 0 };
	struct timeval timeout = { 0, DELAY_USEC };

	/* to store the number of rows and the number of colums of the screen */
 	int row, col, lastrow;
	
	float sxscale, syscale;
	float xscale = 1, yscale = 1;

	int len, fd, ret;

	pos_x = pos_y = old_pos_x = old_pos_y = 0;
	xmin = ymin = 32000;
	xmax = ymax = -32000;

	fd = open("/dev/joy0", O_RDONLY);

	if (fd < 0) {
		printf("Device open error\n");
		return (1);	
	}

	initscr();/* start the curses mode */

	getmaxyx(stdscr,row,col);/* get the number of rows and columns */

	syscale = (float)row / 255;
	sxscale = (float)col / 255;

	col--;

	printw("rows: %i columns:%i sxscale %.5f syscale %.5f delay: %lius\n",
			 row, col, sxscale, syscale, timeout.tv_usec);

	lastrow = row - 1;
	row = row >> 1;
	col = col >> 1;

	ret = read(fd, &joydata, sizeof(joydata));
	if (!ret) {
		endwin();
		printf("Device read error\n");
		return (1);
	}

	rest_x = old_pos_x = joydata.x;
	rest_y = old_pos_y = joydata.y;
	pos_x = pos_y = 0;

	/* calculate screen position */
	delchar_x = col;
	delchar_y = row;

	/* loop */
	for(;;) {
		
		ret = read(fd, &joydata, sizeof(joydata));
		if (!ret) {
			endwin();
			printf("Device read error\n");
			return (1);
		}

		/* calculate screen position */
		char_x = sxscale * joydata.x;
		char_y = syscale * joydata.y;

		/* */

		mvaddch(delchar_y, delchar_x, ' ');
		mvaddch(char_y, char_x, '*');

		mvprintw(2,0,"    x: %4i  y: %4i", joydata.x, joydata.y);
		mvprintw(3,0,"charx: %4i  y: %4i", char_x, char_y);
		mvprintw(lastrow, 0, "Exit: <STRG+C>");

		delchar_x = char_x;
		delchar_y = char_y;

		refresh();

		select(0, NULL, NULL, NULL, &timeout);

	}

	endwin();

	return 0;
}
コード例 #11
0
ファイル: matrix.c プロジェクト: 1451762067/cmatrix
int main(int argc, char **argv)
{
    int  i, j, k = 0;
    int  cnt=0;
    int  arry[170];

    for(i=0; i<170; i++)
        arry[i] = rand()%8;

    init(argc, argv);

    while (1)
    {
        getKey();

        memcpy(Matrix, oldMatrix, sizeof(Matrix)); 
        for(i=0; i<170; i++)
            for(j = Start[i], k=0; k < Space[i]; j++)
            {
                if(j >=50) 
                    j=0;
                Matrix[j][i] = ' ';
                k++;
            }
        
        if(cnt <50 )
        {
            for(i=0; i<170; i++)
                for(j=arry[i]; j< 50; j++)
                    Matrix[j][i]=' ';
            for(i=0; i<170; i++)
            {
                arry[i]++;
                if(arry[i] >=50)
                    arry[i] =50;
            }
            cnt++;
        }
        
        attron(COLOR_PAIR(COLOR_GREEN));
        for(i=0; i< 50; i++)
            for(j=0; j<170; j++)
            {
                 mvaddch(i, j, Matrix[i][j]);
            }
        attroff(COLOR_PAIR(COLOR_GREEN));
        attron(COLOR_PAIR(COLOR_WHITE));
        for(i=0; i< 170; i++)
        {
            mvaddch(Start[i]-1, i, Matrix[Start[i]-1][i]);
            Start[i]++;
            if(Start[i] >= 50)
                Start[i] =0;
        } 
        attroff(COLOR_PAIR(COLOR_WHITE));
  
        refresh();
        //sleep(1);
        napms(Update*10);
    }

    finish();
}
コード例 #12
0
ファイル: grid.c プロジェクト: gridsystem/dvtmx
static void grid(void)
{
	unsigned int i, m, nm, n, nx, ny, nw, nh, aw, ah, cols, rows;
	Client *c;

	for (n = 0, m = 0, c = nextvisible(clients); c; c = nextvisible(c->next), n++)
		if (c->minimized)
			m++;
	/* number of non minimized windows */
	nm = n - m;
	/* grid dimensions */
	for (cols = 0; cols <= nm / 2; cols++)
		if (cols * cols >= nm)
			break;
	rows = (cols && (cols - 1) * cols >= nm) ? cols - 1 : cols;
	/* window geoms (cell height/width) */
	nh = (wah - m) / (rows ? rows : 1);
	nw = waw / (cols ? cols : 1);
	for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next), i++) {
		if (!c->minimized) {
			/* if there are less clients in the last row than normal adjust the
			 * split rate to fill the empty space */
			if (rows > 1 && i == (rows * cols) - cols
			    && (nm - i) <= (nm % cols))
				nw = waw / (nm - i);
			nx = (i % cols) * nw + wax;
			ny = (i / cols) * nh + way;
			/* adjust height/width of last row/column's windows */
			ah = (i >= cols * (rows - 1)) ? wah - m - nh * rows : 0;
			/* special case if there are less clients in the last row */
			if (rows > 1 && i == nm - 1 && (nm - i) < (nm % cols))
				/* (n % cols) == number of clients in the last row */
				aw = waw - nw * (nm % cols);
			else
				aw = ((i + 1) % cols ==
				      0) ? waw - nw * cols : 0;
			if (i % cols) {
				mvvline(ny, nx, THEME_VERT_CHAR, nh + ah);
				/* if we are on the first row, or on the last one and there are fewer clients
				 * than normal whose border does not match the line above, print a top tree char
				 * otherwise a plus sign. */
				if (i <= cols
				    || (i >= rows * cols - cols && nm % cols
					&& (cols - (nm % cols)) % 2))
					mvaddch(ny, nx, THEME_TT_CHAR);
				else
					mvaddch(ny, nx, THEME_PLUS_CHAR);
				nx++, aw--;
			}
		} else {
			if (i == nm) {	/* first minimized client */
				ny = way + wah - m;
				nx = wax;
				nw = waw;
				nh = 1;
				aw = 0;
				ah = 0;
			} else
				ny++;
		}
		resize(c, nx, ny, nw + aw, nh + ah);
	}
}
コード例 #13
0
ファイル: monitor.c プロジェクト: TAEB/moomaster
int main(int argc, char *argv[])
{
	int c;
	char c2 = 'A';
	int idx;
	WINDOW *w;

	window = WINDOW_FRAMEBUFFER;
	w = initscr();
	noecho();
	cbreak();
	nodelay(w, true);

	while (!done)
	{
		c = getch();
		if (c == 'q')
		{
			done = 1;
		}
		else if (c == 'f')
		{
			window = WINDOW_FRAMEBUFFER;
		}
		else if (c == 'n')
		{
			window = WINDOW_NOTEBUFFER;
		}
		else if (c == 't')
		{
			window = WINDOW_TRAFFICBUFFER;
		}
		else if (c == 'p')
		{
			window = WINDOW_NODEBUFFER;
		}
		else if (c == 'k')
		{
			system("killall -USR2 moomaster");
		}
		else if (c == 'u')
		{
			system("killall -USR1 moomaster");
		}
		/*if (!filePtr[window])
		{
			continue;
		}*/
		erase();
		filePtr[WINDOW_FRAMEBUFFER] = fopen("framebuffer.txt", "rb");
		filePtr[WINDOW_NOTEBUFFER] = fopen("notes.txt", "rb");
		filePtr[WINDOW_TRAFFICBUFFER] = fopen("traffic.txt", "rb");
		filePtr[WINDOW_NODEBUFFER] = fopen("nodes.txt", "rb");
		for (idx = 0; idx < 80 * 25; idx++)
		{
			mvaddch(idx / 80, idx % 80, fgetc(filePtr[window]));
			if ((idx % 80) == 79)
			{
				fgetc(filePtr[window]);
			}
		}
		fclose(filePtr[WINDOW_FRAMEBUFFER]);
		fclose(filePtr[WINDOW_NOTEBUFFER]);
		fclose(filePtr[WINDOW_TRAFFICBUFFER]);
		fclose(filePtr[WINDOW_NODEBUFFER]);
		refresh();
		usleep(100000);
	}

	nodelay(w, false);
	nocbreak();
	echo();
	endwin();

	return 0;
}
コード例 #14
0
CHOICE ulDialogueBox::playLine(const dialogueLine &line)
{
    //std::cout<<"char: "<<line.character
    //         <<" exp: "<<line.expression
    //         <<" dia: "<<line.dialogue
    //         <<std::endl;

    regenerateWindows(line);
    drawBorder();
    refresh();

    auto avi = assetManager.get(line.character, line.expression).avatar;
    if (!avi.empty())
    {
        wclear(wAvatar);
        mvwaddstr(wAvatar, 0, 0, avi[0].c_str());
        wrefresh(wAvatar);
    }

    mvaddch(wDialogue.getTop(), wDialogue.getLeft() - 2, '*');

    //float speed = assetManager.get(line.character,line.expression).printSpeed;

    slowPrintDialogue(line);

    if (line.hasOptions)
    {
        slowPrint(wOption1, line.option1, 1.0f);
        slowPrint(wOption2, line.option2, 1.0f);

        attron(COLOR_PAIR(1));
        mvaddstr(optionY, option1X - 2, "\u2665");
        refresh();
        attroff(COLOR_PAIR(1));
    }

    int ch = 0;
    CHOICE rtrn = OPTION_1;
    while (ch != 10 && ch != 'z')
    {
        //std::cout<<"enter: "<<KEY_ENTER<<" z: "<<(int)'z'<<" your key: "<<ch<<std::endl;

        if (line.hasOptions)
        {
            switch (ch)
            {
                case KEY_LEFT:
                    attron(COLOR_PAIR(1));
                    mvaddstr(optionY, option1X - 2, "\u2665");
                    mvaddstr(optionY, option2X - 2, " ");
                    refresh();
                    attroff(COLOR_PAIR(1));

                    mvwaddstr(wOption1, 0, 0, line.option1.c_str()); // TODO: wow this is terrible
                    wrefresh(wOption1);

                    rtrn = OPTION_1;
                    break;

                case KEY_RIGHT:
                    attron(COLOR_PAIR(1));
                    mvaddstr(optionY, option2X - 2, "\u2665");
                    mvaddstr(optionY, option1X - 2, " ");
                    refresh();
                    attroff(COLOR_PAIR(1));

                    mvwaddstr(wOption1, 0, 0, line.option1.c_str()); // TODO: wow this is terrible
                    wrefresh(wOption1);

                    rtrn = OPTION_2;
                    break;

                default:
                    break;
            }
        }

        ch = getch();
    }

    return rtrn;
}
コード例 #15
0
ファイル: rain.c プロジェクト: Brainiarc7/ralink_sdk
static void
part2(DATA * drop)
{
    mvaddch(drop->y, drop->x, 'o');
}
コード例 #16
0
ファイル: map.c プロジェクト: nasciiboy/ncurses
void draw_map( char map[MAP_HSIZE][MAP_WSIZE], int y, int x ){
  int i, ii;
  for(i = 0; i < MAP_HSIZE; i++)
    for(ii = 0; ii < MAP_WSIZE; ii++)
      switch( map[i][ii] ){
      case RIGHT  : mvaddch( y + i, x + ii, '>' | COLOR_PAIR( GB )); break;
      case UP     : mvaddch( y + i, x + ii, '^' | COLOR_PAIR( YB )); break;
      case LEFT   : mvaddch( y + i, x + ii, '<' | COLOR_PAIR( CB )); break;
      case DOWN   : mvaddch( y + i, x + ii, 'v' | COLOR_PAIR( MB )); break;
      case 4      : mvaddch( y + i, x + ii, ' ' | COLOR_PAIR( XX )); break;

      case EMPTY  : mvaddch( y + i, x + ii, EMPTY   | COLOR_PAIR( WB )            ); break;
      case DIRT   : mvaddch( y + i, x + ii, DIRT    | COLOR_PAIR( GG ) | A_NORMAL ); break;
      case STONE  : mvaddch( y + i, x + ii, STONE   | COLOR_PAIR( WB ) | A_NORMAL ); break;
      case DIAMOND: mvaddch( y + i, x + ii, DIAMOND | COLOR_PAIR( YB ) | A_BOLD   ); break;
      case WALL   : mvaddch( y + i, x + ii, WALL    | COLOR_PAIR( CB ) | A_NORMAL ); break;
      case MONEY  : mvaddch( y + i, x + ii, MONEY   | COLOR_PAIR( GB ) | A_NORMAL ); break;
      case PLAYER : mvaddch( y + i, x + ii, PLAYER  | COLOR_PAIR( WB ) | A_BOLD   ); break;
      case BOMB   : mvaddch( y + i, x + ii, BOMB    | COLOR_PAIR( XB ) | A_BOLD   ); break;
      case BOMBPK : mvaddch( y + i, x + ii, BOMBPK  | COLOR_PAIR( XB ) | A_BOLD   ); break;
      case MONSTER: mvaddch( y + i, x + ii, MONSTER | COLOR_PAIR( MB ) | A_BOLD   ); break;
      case BLOOD  : mvaddch( y + i, x + ii, BLOOD   | COLOR_PAIR( YB ) | A_BOLD   ); break;
      default     : mvaddch( y + i, x + ii, '?'                                   ); break;
      }

}
コード例 #17
0
ファイル: rain.c プロジェクト: Brainiarc7/ralink_sdk
static void
part3(DATA * drop)
{
    mvaddch(drop->y, drop->x, 'O');
}
コード例 #18
0
ファイル: nCurse.C プロジェクト: chandl34/public
void nCurse::PutCharAt(int x,int y,unsigned short ch) {
    if (running) mvaddch(y,x,ch);
}
コード例 #19
0
ファイル: editor.c プロジェクト: Bencepapa/CymonsGames
void ShowEditorWindow()
{
	unsigned int i;
	clear();
	ShowEditorMap();
	attrset(COLOR_PAIR(COLOR_WHITE));
	mvaddstr(20,0,"F1-terrain  F2-units  F5-test");
	mvaddstr(21,0,"F8-save     F9-load   F12-clear/fill");
	if (editing_terrain)
	{		
		for (i=0;i<TERRAIN_MAX;++i)
		{
			if (terrain_prop[i].color!=COLOR_WHITE)
				attrset(COLOR_PAIR(terrain_prop[i].color|COLOR_WHITE*8));
			else
				attrset(COLOR_PAIR(COLOR_BLACK|COLOR_WHITE*8));
			mvprintw(22,i,"%c",terrain_prop[i].tile);
			if (i==current_terrain)
			{
				attrset(COLOR_PAIR(COLOR_WHITE));
				mvprintw(23,0,"Current:");
				mvprintw(23,11,"%s",terrain_prop[i].name);
				attrset(COLOR_PAIR(terrain_prop[i].color));
				mvprintw(23,9,"%c", terrain_prop[i].tile);
			}			
		}		
	}
	else
	{
		for (i=0;i<UNIT_TYPE_MAX;++i)
		{
			if (editing_blue)
				attrset(COLOR_PAIR(COLOR_WHITE|COLOR_BLUE*8)|A_BOLD);
			else
				attrset(COLOR_PAIR(COLOR_WHITE|COLOR_RED*8)|A_BOLD);
			mvprintw(22,i,"%c",unit_prop[i].tile);
			if (i==current_unit)
			{
				mvprintw(23,9,"%c", unit_prop[i].tile);
				attrset(COLOR_PAIR(COLOR_WHITE));
				mvprintw(23,0,"Current:");
				mvprintw(23,11,"%s",unit_prop[i].name);
			}			
		}	
		if (current_unit==UNIT_TYPE_MAX)
		{
			attrset(COLOR_PAIR(COLOR_WHITE));
			mvprintw(23,0,"Current: Remove");
		}
		if (editing_blue)
		{
			attrset(COLOR_PAIR(COLOR_WHITE|COLOR_RED*8)|A_BOLD);
			mvaddch(22,i+1,' ');
		}
		else
		{
			attrset(COLOR_PAIR(COLOR_WHITE|COLOR_BLUE*8)|A_BOLD);
			mvaddch(22,i+1,' ');
		}
		attrset(COLOR_PAIR(COLOR_WHITE));
		mvprintw(22,30,"Blue: %d",blue_units_left);
		mvprintw(23,30,"Red:  %d",red_units_left);

	}
	move(cursor_y,cursor_x);
	refresh();
}
コード例 #20
0
void texteditor(char *text)
    {
    int ky=0,position=0,row,col;
    char *where, display[20][81];
    bool ins=false;

    while (ky !=KEY_F(1))
        {
        where=text;
        for (row=19; row > -1; row--)
            {
            move(row,0);
            clrtoeol();
            display[row][0]=127;
            display[row][1]='\0';
            }
        row=0;
        while (strlen(where) > 80 || strchr(where,'~') != NULL)
            {
            strncpy(display[row],where,80);
            display[row][80]='\0';
            if (strchr(display[row],'~') != NULL)
                {
                left(display[row],strchr(display[row],'~')-display[row]);
                }
            else
                left(display[row],strrchr(display[row],' ')-display[row]);
            mvprintw(row,0,"%s",display[row]);
            where+=strlen(display[row])+1;
            row++;
            }
        strcpy(display[row],where);
        mvprintw(row,0,"%s",display[row]);
        col=position;
        row=0;
        while (col > strlen(display[row]))
            {
            col-=strlen(display[row])+1;
            row++;
            }
        move(row,col);
        
        ky=getch();
        switch(ky)
            {
            case KEY_F(3):
                memset(text,0,1621);
                position=0;
                break;
            case KEY_HOME:
                if (col)
                    {
                    position=0;
                    for (col=0; col < row; col++)
                        position += strlen(display[col])+1;
                    }
                break;
            case KEY_END:
                if (col < strlen(display[row]))
                    {
                    position=-1;
                    for (col=0; col <=row; col++)
                        position+=strlen(display[col])+1;
                    }
                break;
            case KEY_LEFT:
                if (position)
                    position--;
                break;
            case KEY_RIGHT:
                if (position < strlen(text))
                    position++;
                break;
            case KEY_UP:
                if (row)
                    {
                    if (col > strlen(display[row-1]))
                        position=strlen(display[row-1]);
                    else
                        position=col;
                    for (col=0; col < row-1; col++)
                        position+=strlen(display[col])+1;
                    }
                break;
            case KEY_DOWN:
                if (display[row+1][0] !=127 && row < 19)
                    {
                    if (col < strlen(display[row+1]))
                        position=col;
                    else
                        position=strlen(display[row+1]);
                    for (col=0; col <= row; col++)
                        position+=strlen(display[col])+1;
                    }   
                break;
            case KEY_IC: // insert key
                ins = !ins;
                if (ins)
                    mvaddstr(20,77,"INS");
                else
                    {
                    mvaddch(20,77,ACS_CKBOARD);
                    addch(ACS_CKBOARD);
                    addch(ACS_CKBOARD);
                    }
                break;
            case KEY_DC:  // delete key
                if (strlen(text))
                    memmove(&text[position],&text[position+1],1621-position);
                break;
            case KEY_BACKSPACE:
                if (strlen(text) && position)
                    {
                    position--;
                    memmove(&text[position],&text[position+1],1621-position);
                    }
                break;
            case 25: // ctrl-y
                position=0;
                for (col=0; col < row; col++)
                    position+=strlen(display[col])+1;
                memmove(&text[position],&text[position+strlen(display[row])+1],1621-position+strlen(display[row]));
                break;
            case 10: // return
                if (display[19][0] == 127 || display[19][0] == '~')
                    {
                    memmove(&text[position+1],&text[position],1621-position);
                    text[position]='~';
                    position++;
                    }
                break;
            default:
                if (ky > 31 && ky < 126 && (row !=19 || (strlen(display[19]) < 79) || (!ins && (row!=19 && col <79 ))))
                    {
                    if (ins || text[position+1]=='~' || text[position]== '~')
                        memmove(&text[position+1],&text[position],1621-position);
                    text[position]=ky;
                    position++;
                    }
                    
            }
        }
    return;
    }
コード例 #21
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_brick(int y, int x){
	attron(COLOR_PAIR(3));
	mvaddch(y, x, ACS_PLUS);
	attroff(A_BOLD);
	matrix[y - y1b][x - x1b] = 'b';
}
コード例 #22
0
ファイル: main.cpp プロジェクト: discoloda/Projects
 void put(int x, int y, char c, int flags = 0) {
     mvaddch(y, x, c);
 }
コード例 #23
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_tank_status(int y, int x, TankDesign *tank_type, int *position, int A){

	switch (A){
	case 0: attron(COLOR_PAIR(1) | A_BOLD); mvaddch(y + 3, x, 'N'); attroff(COLOR_PAIR(1) | A_BOLD); break;
	case 1: attron(COLOR_PAIR(1) | A_BOLD); mvaddch(y + 3, x, 'S'); attroff(COLOR_PAIR(1) | A_BOLD); break;
	}

	attron(COLOR_PAIR(tank_type[position[0]].paint));
	mvaddch(y - 1, x - 1, tank_type[position[0]].ch);

	attron(COLOR_PAIR(tank_type[position[1]].paint));
	mvaddch(y - 1, x, tank_type[position[1]].ch);

	attron(COLOR_PAIR(tank_type[position[2]].paint));
	mvaddch(y - 1, x + 1, tank_type[position[2]].ch);

	attron(COLOR_PAIR(tank_type[position[3]].paint));
	mvaddch(y, x - 1, tank_type[position[3]].ch);

	attron(COLOR_PAIR(tank_type[position[4]].paint));
	mvaddch(y, x, tank_type[position[4]].ch);

	attron(COLOR_PAIR(tank_type[position[5]].paint));
	mvaddch(y, x + 1, tank_type[position[5]].ch);

	attron(COLOR_PAIR(tank_type[position[6]].paint));
	mvaddch(y + 1, x - 1, tank_type[position[6]].ch);

	attron(COLOR_PAIR(tank_type[position[7]].paint));
	mvaddch(y + 1, x, tank_type[position[7]].ch);

	attron(COLOR_PAIR(tank_type[position[8]].paint));
	mvaddch(y + 1, x + 1, tank_type[position[8]].ch);

	refresh();
}
コード例 #24
0
ファイル: tg_view.c プロジェクト: nathanhaigh/staden-trunk
static void display_gap(GapIO *io, contig_t **c, int xpos, int ypos,
                        int nlines, int wid, int mode, int qual_cutoff,
                        int in_curses) {
    rangec_t *r;
    int i, nr, lno, y;
    char line[1024], *lp;
    char cons[1024];
    int attr;
    static int lookup_1conf[256];
    static int lookup_4conf[256];
    static int lookup_init = 0;

    if (!lookup_init) {
        for (i = 0; i < 256; i++)
            lookup_1conf[i] = lookup_4conf[0] = 0;

        lookup_4conf['a'] = lookup_4conf['A'] = 0;
        lookup_4conf['c'] = lookup_4conf['C'] = 1;
        lookup_4conf['g'] = lookup_4conf['G'] = 2;
        lookup_4conf['t'] = lookup_4conf['T'] = 3;
    }

    wid -= MAX_NAME_LEN+2;

    //if (xpos < wid/2 + (*c)->start)
    //	xpos = wid/2 + (*c)->start;

    xpos -= wid/2;

    /* Query visible objects */
    r = contig_seqs_in_range(io, c, xpos, xpos+wid-1, CSIR_SORT_BY_X, &nr);

    /* Consensus */
    calc_cons(io, r, nr, xpos, wid, cons);
    if (in_curses) {
        clear();
        mvaddnstr(0, 1, contig_get_name(c), strlen(contig_get_name(c)));
        mvaddnstr(0, MAX_NAME_LEN+2, cons, wid);
    } else {
        printf(" %-*s %.*s\n", MAX_NAME_LEN, contig_get_name(c), wid, cons);
    }

    /* Position */
    for (lp = line, i = xpos; i < xpos+wid+19; i++) {
        if (i % 10 == 0) {
            sprintf(lp, "%10d", i-10);
            lp += 10;
        }
    }
    if (in_curses) {
        int m = (xpos-1)%10;
        if (m < 0) m += 10;
        mvaddnstr(1, MAX_NAME_LEN+2, line+10+m, wid);
    } else {
        printf("%*s%.*s\n", MAX_NAME_LEN+2, "", wid,
               line+9+((xpos-1)%10));
    }


    /* Sequences */
    for (i = y = 0; i < nr && y < ypos; i++, y++);
    for (lno = 2; i < nr && lno < nlines; i++, lno++) {
        seq_t *s = get_seq(io, r[i].rec);
        seq_t *sorig = s;
        int sp = r[i].start;
        int l = s->len > 0 ? s->len : -s->len;
        unsigned char seq_a[MAX_SEQ_LEN], *seq = seq_a;
        int j, dir = '+';
        int left, right;
        char *conf;
        int nc = s->format == SEQ_FORMAT_CNF4 ? 4 : 1;
        int *L = s->format == SEQ_FORMAT_CNF4 ? lookup_4conf : lookup_1conf;

        /* Complement data on-the-fly */
        if ((s->len < 0) ^ r[i].comp) {
            dir = '-';
            s = dup_seq(s);
            complement_seq_t(s);
        }

        left = s->left;
        right = s->right;

        memcpy(seq, s->seq, l);
        conf = s->conf;

        if (sp < xpos) {
            seq   += xpos - sp;
            conf  += nc * (xpos - sp);
            l     -= xpos - sp;
            left  -= xpos - sp;
            right -= xpos - sp;
            sp = xpos;
        }
        if (l > wid - (sp-xpos))
            l = wid - (sp-xpos);

        if (in_curses) {
            /* Test of sequence_get_position */
            /*
              int c, p;
              sequence_get_position(io, r[i].rec, &c, &p);
              s->name_len = sprintf(s->name, ":%d-%d:", p, p+ABS(s->len)-1);
            */
            mvaddch(lno, 0, dir);
            addnstr(s->name, MIN(MAX_NAME_LEN, s->name_len));
            move(lno, MAX_NAME_LEN+2+sp-xpos);
        } else {
            printf("%c%.*s%*s",
                   dir,
                   MIN(MAX_NAME_LEN, s->name_len), s->name,
                   MAX_NAME_LEN+1-MIN(MAX_NAME_LEN, s->name_len) +sp-xpos, "");
        }

        for (j = 0; j < l; j++) {
            attr = (mode & DISPLAY_COLOURS) ? COLOR_PAIR(lookup[seq[j]]) : 0;

            if (mode & DISPLAY_DIFFS
                    && sp-xpos+j < wid && seq[j] == cons[sp-xpos+j])
                seq[j] = '.';
            if (j < left-1 || j > right-1)
                seq[j] = (mode & DISPLAY_CUTOFFS) ? tolower(seq[j]) : ' ';

            if (conf[j*nc+L[seq[j]]] >= qual_cutoff && mode & DISPLAY_QUAL) {
                attr |= A_BOLD;
            }

            if (in_curses) {
                addch(seq[j] | attr);
            } else {
                putchar(seq[j]);
            }
        }

        if (!in_curses)
            putchar('\n');

        if (s != sorig)
            free(s);
    }

    /* Useful debugging code to show bin locations. */
#if 0
    free(r);
    r = contig_bins_in_range(io, c, xpos, xpos+wid-1, &nr);
    /* Bins */
    for (i=0; i < nr && lno < nlines; i++, lno++) {
        bin_index_t *bin = (bin_index_t *)cache_search(io, GT_Bin, r[i].rec);
        unsigned char *seq, *seqm;
        int j, dir = "+-"[r[i].comp];
        int sp = r[i].start;
        int l = ABS(r[i].end - r[i].start + 1);
        char name[100];

        sprintf(name, "bin-%d", bin->rec);
        seqm = seq = malloc(l+1);
        memset(seq, '-', l);

        if (!(bin->start_used == 0 && bin->end_used == 0)) {
            if (r[i].comp) {
                memset(&seq[bin->size - bin->end_used - 1], '=',
                       bin->end_used - bin->start_used + 1);
            } else {
                memset(&seq[bin->start_used], '=',
                       bin->end_used - bin->start_used + 1);
            }
        }

        /*
        fprintf(stderr, "Bin-%d: %d+%d %d..%d\n",
        	bin->rec,
        	bin->pos, bin->size,
        	bin->start_used, bin->end_used);
        */

        if (sp < xpos) {
            seq   += xpos - sp;
            l     -= xpos - sp;
            sp = xpos;
        }
        if (l > wid - (sp-xpos))
            l = wid - (sp-xpos);

        if (in_curses) {
            mvaddch(lno, 0, dir);
            addnstr(name, strlen(name));
            move(lno, MAX_NAME_LEN+2+sp-xpos);
        } else {
            printf("%c%.*s%*s",
                   dir,
                   (int)MIN(MAX_NAME_LEN, strlen(name)),
                   name,
                   (int)(MAX_NAME_LEN+1-MIN(MAX_NAME_LEN,
                                            strlen(name)) +sp-xpos),
                   "");
        }

        for (j = 0; j < l; j++) {
            if (in_curses) {
                addch(seq[j]);
            } else {
                putchar(seq[j]);
            }
        }

        if (!in_curses)
            putchar('\n');

        free(seqm);
    }
#endif

    if (in_curses)
        refresh();

    free(r);
}
コード例 #25
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_wall(int y, int x){
	attron(COLOR_PAIR(13));
	mvaddch(y, x, ACS_PLUS | A_BOLD);
	matrix[y - y1b][x - x1b] = 'c';
}
コード例 #26
0
ファイル: pack.c プロジェクト: Elronnd/rogomatic
void
add_pack(THING *obj, bool silent)
{
    THING *op, *lp;
    bool from_floor;

    from_floor = FALSE;
    if (obj == NULL)
    {
	if ((obj = find_obj(hero.y, hero.x)) == NULL)
	    return;
	from_floor = TRUE;
    }

    /*
     * Check for and deal with scare monster scrolls
     */
    if (obj->o_type == SCROLL && obj->o_which == S_SCARE)
	if (obj->o_flags & ISFOUND)
	{
	    detach(lvl_obj, obj);
	    mvaddch(hero.y, hero.x, floor_ch());
	    chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR;
	    discard(obj);
	    msg("the scroll turns to dust as you pick it up");
	    return;
	}

    if (pack == NULL)
    {
	pack = obj;
	obj->o_packch = pack_char();
	inpack++;
    }
    else
    {
	lp = NULL;
	for (op = pack; op != NULL; op = next(op))
	{
	    if (op->o_type != obj->o_type)
		lp = op;
	    else
	    {
		while (op->o_type == obj->o_type && op->o_which != obj->o_which)
		{
		    lp = op;
		    if (next(op) == NULL)
			break;
		    else
			op = next(op);
		}
		if (op->o_type == obj->o_type && op->o_which == obj->o_which)
		{
		    if (ISMULT(op->o_type))
		    {
			if (!pack_room(from_floor, obj))
			    return;
			op->o_count++;
dump_it:
			discard(obj);
			obj = op;
			lp = NULL;
			goto out;
		    }
		    else if (obj->o_group)
		    {
			lp = op;
			while (op->o_type == obj->o_type
			    && op->o_which == obj->o_which
			    && op->o_group != obj->o_group)
			{
			    lp = op;
			    if (next(op) == NULL)
				break;
			    else
				op = next(op);
			}
			if (op->o_type == obj->o_type
			    && op->o_which == obj->o_which
			    && op->o_group == obj->o_group)
			{
				op->o_count += obj->o_count;
				inpack--;
				if (!pack_room(from_floor, obj))
				    return;
				goto dump_it;
			}
		    }
		    else
			lp = op;
		}
out:
		break;
	    }
	}

	if (lp != NULL)
	{
	    if (!pack_room(from_floor, obj))
		return;
	    else
	    {
		obj->o_packch = pack_char();
		next(obj) = next(lp);
		prev(obj) = lp;
		if (next(lp) != NULL)
		    prev(next(lp)) = obj;
		next(lp) = obj;
	    }
	}
    }

    obj->o_flags |= ISFOUND;

    /*
     * If this was the object of something's desire, that monster will
     * get mad and run at the hero.
     */
    for (op = mlist; op != NULL; op = next(op))
	if (op->t_dest == &obj->o_pos)
	    op->t_dest = &hero;

    if (obj->o_type == AMULET)
	amulet = TRUE;
    /*
     * Notify the user
     */
    if (!silent)
    {
	if (!terse)
	    addmsg("you now have ");
	msg("%s (%c)", inv_name(obj, !terse), obj->o_packch);
    }
}
コード例 #27
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_white(int y, int x)
{
	attron(COLOR_PAIR(13));
	mvaddch(y, x, ACS_BOARD);
	matrix[y - y1b][x - x1b] = 'h';
}
コード例 #28
0
ファイル: rain.c プロジェクト: Brainiarc7/ralink_sdk
static void
part1(DATA * drop)
{
    mvaddch(drop->y, drop->x, '.');
}
コード例 #29
0
ファイル: graphic.c プロジェクト: vasa137/Battle-Tank
void print_tank(int y, int x, TankDesign *tank_type, int *position)
{
	if (matrix[y - 1 - y1b][x - 1 - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[0][0] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[0]].paint));
		mvaddch(y - 1, x - 1, tank_type[position[0]].ch);
	}
	matrix[y - 1 - y1b][x - 1 - x1b] = 't';

	if (matrix[y - 1 - y1b][x - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[0][1] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[1]].paint));
		mvaddch(y - 1, x, tank_type[position[1]].ch);
	}
	matrix[y - 1 - y1b][x - x1b] = 't';

	if (matrix[y - 1 - y1b][x + 1 - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[0][2] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[2]].paint));
		mvaddch(y - 1, x + 1, tank_type[position[2]].ch);
	}
	matrix[y - 1 - y1b][x + 1 - x1b] = 't';

	if (matrix[y - y1b][x - 1 - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[1][0] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[3]].paint));
		mvaddch(y, x - 1, tank_type[position[3]].ch);
	}
	matrix[y - y1b][x - 1 - x1b] = 't';

	if (matrix[y - y1b][x - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[1][1] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[4]].paint));
		mvaddch(y, x, tank_type[position[4]].ch);
	}
	matrix[y - y1b][x - x1b] = 't';

	if (matrix[y - y1b][x + 1 - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[1][2] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[5]].paint));
		mvaddch(y, x + 1, tank_type[position[5]].ch);
	}
	matrix[y - y1b][x + 1 - x1b] = 't';

	if (matrix[y + 1 - y1b][x - 1 - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[2][0] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[6]].paint));
		mvaddch(y + 1, x - 1, tank_type[position[6]].ch);
	}
	matrix[y + 1 - y1b][x - 1 - x1b] = 't';

	if (matrix[y + 1 - y1b][x - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[2][1] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[7]].paint));
		mvaddch(y + 1, x, tank_type[position[7]].ch);
	}
	matrix[y + 1 - y1b][x - x1b] = 't';

	if (matrix[y + 1 - y1b][x + 1 - x1b] == 'g') lst->curr->tankAll.tank.visit_grass[2][2] = 1;
	else{
		attron(COLOR_PAIR(tank_type[position[8]].paint));
		mvaddch(y + 1, x + 1, tank_type[position[8]].ch);
	}
	matrix[y + 1 - y1b][x + 1 - x1b] = 't';


	refresh();
}
コード例 #30
0
ファイル: ui.c プロジェクト: Lekensteyn/radeontop
void present(const unsigned int ticks, const char card[], unsigned int color) {

	printf(_("Collecting data, please wait....\n"));

	// This does not need to be atomic. A delay here is acceptable.
	while(!results)
		usleep(16000);

	initscr();
	noecho();
	halfdelay(10);
	curs_set(0);
	clear();

	start_color();
	init_pair(1, COLOR_GREEN, COLOR_BLACK);
	init_pair(2, COLOR_RED, COLOR_BLACK);
	init_pair(3, COLOR_CYAN, COLOR_BLACK);
	init_pair(4, COLOR_MAGENTA, COLOR_BLACK);
	init_pair(5, COLOR_YELLOW, COLOR_BLACK);

	const unsigned int bigh = 23;

	unsigned int w, h;
	getmaxyx(stdscr, h, w);

	const unsigned int hw = w/2;

	attron(A_REVERSE);
	mvhline(0, 0, ' ', w);
	printcenter(0, w, _("radeontop %s, running on %s, %u samples/sec"),
			VERSION, card, 	ticks);
	attroff(A_REVERSE);

	while(1) {

		move(2, 0);
		clrtobot();

		// Again, no need to protect these. Worst that happens is a slightly
		// wrong number.
		float ee = 100.0 * (float) results->ee / ticks;
		float vgt = 100.0 * (float) results->vgt / ticks;
		float gui = 100.0 * (float) results->gui / ticks;
		float ta = 100.0 * (float) results->ta / ticks;
		float tc = 100.0 * (float) results->tc / ticks;
		float sx = 100.0 * (float) results->sx / ticks;
		float sh = 100.0 * (float) results->sh / ticks;
		float spi = 100.0 * (float) results->spi / ticks;
		float smx = 100.0 * (float) results->smx / ticks;
		float sc = 100.0 * (float) results->sc / ticks;
		float pa = 100.0 * (float) results->pa / ticks;
		float db = 100.0 * (float) results->db / ticks;
		float cr = 100.0 * (float) results->cr / ticks;
		float cb = 100.0 * (float) results->cb / ticks;
		float vram = 100.0 * (float) results->vram / vramsize;
		float vrammb = results->vram / 1024.0f / 1024.0f;
		float vramsizemb = vramsize / 1024.0f / 1024.0f;

		mvhline(3, 0, ACS_HLINE, w);
		mvvline(1, (w/2) + 1, ACS_VLINE, h);
		mvaddch(3, (w/2) + 1, ACS_PLUS);

		if (color) attron(COLOR_PAIR(1));
		percentage(2, w, gui);
		printright(2, hw, _("Graphics pipe %6.2f%%"), gui);
		if (color) attroff(COLOR_PAIR(1));

		unsigned int start = 4;

		percentage(start, w, ee);
		printright(start++, hw, _("Event Engine %6.2f%%"), ee);

		// Enough height?
		if (h > bigh) start++;

		if (color) attron(COLOR_PAIR(2));
		percentage(start, w, vgt);
		printright(start++, hw, _("Vertex Grouper + Tesselator %6.2f%%"), vgt);
		if (color) attroff(COLOR_PAIR(2));

		// Enough height?
		if (h > bigh) start++;

		if (color) attron(COLOR_PAIR(3));
		percentage(start, w, ta);
		printright(start++, hw, _("Texture Addresser %6.2f%%"), ta);

		// This is only present on R600
		if (bits.tc) {
			percentage(start, w, tc);
			printright(start++, hw, _("Texture Cache %6.2f%%"), tc);
		}
		if (color) attroff(COLOR_PAIR(3));

		// Enough height?
		if (h > bigh) start++;

		if (color) attron(COLOR_PAIR(4));
		percentage(start, w, sx);
		printright(start++, hw, _("Shader Export %6.2f%%"), sx);

		percentage(start, w, sh);
		printright(start++, hw, _("Sequencer Instruction Cache %6.2f%%"), sh);

		percentage(start, w, spi);
		printright(start++, hw, _("Shader Interpolator %6.2f%%"), spi);

		// only on R600
		if (bits.smx) {
			percentage(start, w, smx);
			printright(start++, hw, _("Shader Memory Exchange %6.2f%%"), smx);
		}
		if (color) attroff(COLOR_PAIR(4));

		// Enough height?
		if (h > bigh) start++;

		percentage(start, w, sc);
		printright(start++, hw, _("Scan Converter %6.2f%%"), sc);

		percentage(start, w, pa);
		printright(start++, hw, _("Primitive Assembly %6.2f%%"), pa);

		// Enough height?
		if (h > bigh) start++;

		if (color) attron(COLOR_PAIR(5));
		percentage(start, w, db);
		printright(start++, hw, _("Depth Block %6.2f%%"), db);

		percentage(start, w, cb);
		printright(start++, hw, _("Color Block %6.2f%%"), cb);

		// Only present on R600
		if (bits.cr) {
			percentage(start, w, cr);
			printright(start++, hw, _("Clip Rectangle %6.2f%%"), cr);
		}
		if (color) attroff(COLOR_PAIR(5));

		// Enough height?
		if (h > bigh) start++;

		if (bits.vram) {
			if (color) attron(COLOR_PAIR(2));
			percentage(start, w, vram);
			printright(start++, hw, _("%.0fM / %.0fM VRAM %6.2f%%"),
					vrammb, vramsizemb, vram);
			if (color) attroff(COLOR_PAIR(2));
		}

		refresh();

		int c = getch();
		if (c == 'q' || c == 'Q') break;
		if (c == 'c' || c == 'C') color = !color;
	}

	endwin();
}