Пример #1
0
void
hallucinate(void)
{
	object *obj, *monster;
	short ch;

	if (blind) return;

	obj = level_objects.next_object;

	while (obj) {
		ch = mvinch(obj->row, obj->col);
		if (((ch < 'A') || (ch > 'Z')) &&
		    ((obj->row != rogue.row) || (obj->col != rogue.col)))
		{
			if ((ch != ' ') && (ch != '.') && (ch != '#') &&
			    (ch != '+'))
			{
				addch(gr_obj_char());
			}
		}
		obj = obj->next_object;
	}
	monster = level_monsters.next_monster;

	while (monster) {
		ch = mvinch(monster->row, monster->col);
		if ((ch >= 'A') && (ch <= 'Z')) {
			addch(get_rand('A', 'Z'));
		}
		monster = monster->next_monster;
	}
}
Пример #2
0
/*
 * domaze:
 *	Draw the maze on this level.
 */
do_maze()
{
	reg int least;
	reg struct room *rp;
	reg struct linked_list *item;
	reg struct object *obj;
	int cnt;
	bool treas;
	coord tp;

	for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) {
		rp->r_flags = ISGONE;		/* kill all rooms */
		rp->r_fires = NULL;		/* no fires */
	}
	rp = &rooms[0];				/* point to only room */
	rp->r_flags = ISDARK;			/* mazes always dark */
	rp->r_pos.x = 0;			/* room fills whole screen */
	rp->r_pos.y = 1;
	rp->r_max.x = cols - 1;
	rp->r_max.y = lines - 3;
	draw_maze();				/* put maze into window */
	/*
	 * add some gold to make it worth looking for 
	 */
	item = spec_item(GOLD, NULL, NULL, NULL);
	obj = OBJPTR(item);
	obj->o_count *= (rnd(5) + 5);		/* add in one large hunk */
	attach(lvl_obj, item);
	cnt = 0;
	do {
	    rnd_pos(rp, &tp);
	} until (mvinch(tp.y, tp.x) == FLOOR || cnt++ > 5000);
	mvaddch(tp.y, tp.x, GOLD);
	obj->o_pos = tp;
	/*
	 * add in some food to make sure he has enough
	 */
	item = spec_item(FOOD, NULL, NULL, NULL);
	obj = OBJPTR(item);
	attach(lvl_obj, item);
	do {
	    rnd_pos(rp, &tp);
	} until (mvinch(tp.y, tp.x) == FLOOR || cnt++ > 5000);
	mvaddch(tp.y, tp.x, FOOD);
	obj->o_pos = tp;
	if (rnd(100) < 40) {			/* treasure type maze */
		treas = TRUE;
		least = 10;
		debug("treasure maze");
	}
	else {					/* normal maze level */
		least = 5;
		treas = FALSE;
	}
	genmonsters(least, treas);
}
Пример #3
0
//右3マスに敵がいるかどうか。
int sensor_K(Agent_status *strAGENT)
{
    int flag = 0;
    if(mvinch(strAGENT->Y,strAGENT->X+1) == '*' ||
       mvinch(strAGENT->Y,strAGENT->X+2) == '*' ||
       mvinch(strAGENT->Y,strAGENT->X+3) == '*')
    {
        flag = 1;
    }
    return 0;
}
Пример #4
0
char getcfd(coord cord, int dir) //1 = up, 2 = down, 3 = left, 4 = right
{
	if(dir == 1)
		return mvinch(cord.y - 1, cord.x);
	else if(dir == 2)
		return mvinch(cord.y + 1, cord.x);
	else if(dir == 3)
		return mvinch(cord.y, cord.x - 1);
	else if(dir == 4)
		return mvinch(cord.y, cord.x + 1);
	return 0;
}
void
move_mon_to(object *monster, short row, short col)
{
	short c;
	int mrow, mcol;

	mrow = monster->row;
	mcol = monster->col;

	dungeon[mrow][mcol] &= ~MONSTER;
	dungeon[row][col] |= MONSTER;

	c = mvinch(mrow, mcol);

	if ((c >= 'A') && (c <= 'Z')) {
		if (!detect_monster) {
			mvaddch(mrow, mcol, monster->trail_char);
		} else {
			if (rogue_can_see(mrow, mcol)) {
				mvaddch(mrow, mcol, monster->trail_char);
			} else {
				if (monster->trail_char == '.') {
					monster->trail_char = ' ';
				}
				mvaddch(mrow, mcol, monster->trail_char);
			}
		}
	}
	monster->trail_char = mvinch(row, col);
	if (!blind && (detect_monster || rogue_can_see(row, col))) {
		if ((!(monster->m_flags & INVISIBLE) ||
			(detect_monster || see_invisible || r_see_invisible))) {
			mvaddch(row, col, gmc(monster));
		}
	}
	if ((dungeon[row][col] & DOOR) &&
		(get_room_number(row, col) != cur_room) &&
		(dungeon[mrow][mcol] == FLOOR) && !blind) {
			mvaddch(mrow, mcol, ' ');
	}
	if (dungeon[row][col] & DOOR) {
			dr_course(monster, ((dungeon[mrow][mcol] & TUNNEL) ? 1 : 0),
				row, col);
	} else {
		monster->row = row;
		monster->col = col;
	}
}
Пример #6
0
//重力
int Gravity(int stgnum,Agent_status *agent, node_t *trees,int auto_or_mamual,Girl *Girl_status){

    //慣性を監視
    //    mvprintw(0,0,"intertia = %d",agent->INTERTIA);
    if (agent->END_FLAG != 1)
    {    
        if (agent->X >= Girl_status->X)
        {
            END(1,stgnum,trees,auto_or_mamual,agent);
            return 0;
        }
        else if (agent->Y > Girl_status->Y+8)
        {
            END(0,stgnum,trees,auto_or_mamual,agent);
            return 0;
        }


        printBoy(agent,stgnum);

        if(mvinch(agent->Y+1,agent->X) != 'I')
        {
            agent->Y += 1;
            control(stgnum,agent,trees,auto_or_mamual,Girl_status);
            //            usleep(80000);
            moveRoL(agent);
            Gravity(stgnum,agent,trees,auto_or_mamual,Girl_status);
        }
    }
    return 0;
}
Пример #7
0
void save_screen(void)
{
	FILE *fp;
	short i, j;
	char buf[DCOLS+2];
	boolean found_non_blank;


	if ((fp = fopen("rogue.screen", "w")) != NULL)
	{
		for (i = 0; i < DROWS; i++)
		{
			found_non_blank = 0;
			for (j = (DCOLS - 1); j >= 0; j--)
			{
				buf[j] = mvinch(i, j);
				if (!found_non_blank)
				{
					if ((buf[j] != ' ') || (j == 0))
					{
						buf[j + ((j == 0) ? 0 : 1)] = 0;
						found_non_blank = 1;
					}
				}
			}
			fputs(buf, fp);
			putc('\n', fp);
		}
		fclose(fp);
	}
	else
	{
		sound_bell();
	}
}
Пример #8
0
void enemyObjChk(Enemy * enemy[20], int eneNum, int yChange, int xChange, Player * chris)
{
    //declare variable
    char newLoc;

    //target location
    newLoc = mvinch(enemy[eneNum]->yPos+yChange, enemy[eneNum]->xPos+xChange);

    //kill event
    if(enemy[eneNum]->health<1 && enemy[eneNum]->type!='.')
    {
        moveText();
        mvprintw(56, 10, "You killed a %s!", getWord(enemy[eneNum]->type));
        enemy[eneNum]->type = '.';
    }

    //case 1: clear: move there
    if(newLoc == '.')
    {
        mvaddch(enemy[eneNum]->yPos, enemy[eneNum]->xPos, '.');
        mvaddch(enemy[eneNum]->yPos + yChange, enemy[eneNum]->xPos +xChange, enemy[eneNum]->type);
        enemy[eneNum]->xPos += xChange;
        enemy[eneNum]->yPos += yChange;
    }

    //case 2: hero: attack
    else if(newLoc == '@')
    {
        combat(enemy[eneNum]->yPos, enemy[eneNum]->xPos, chris, enemy);
    }
    //otherwise creature will not be able to move
}//end of enemyObjChk
Пример #9
0
int   ABullet::move(void) // Returns 1 or 2 if collision
{
	if (side)
	{
		this->pos.x++;
		if ((mvinch(this->pos.y, this->pos.x + 1) & A_COLOR) == COLOR_PAIR(1))
			return (1);
	}
	else
	{
		this->pos.x--;
		if ((mvinch(this->pos.y, this->pos.x) & A_COLOR) == COLOR_PAIR(2))
			return (2);
	}
	return (0);
}
Пример #10
0
cell pp_curs_mvinch(cell x) {
	char	name[] = "curs:mvinch";

	if (!Running) return UNSPECIFIC;
	return make_char((int) mvinch(integer_value(name, car(x)),
			integer_value(name, cadr(x))));
}
Пример #11
0
int len(int lineno)
{
   int linelen = COLS - 1;

   while (linelen >= 0 && mvinch(lineno, linelen) == ' ')
       linelen--;
   return linelen + 1;
}
Пример #12
0
int main(int argc,char **argv)
{
   //extern void perror(), exit();
   int i, n, l;
   int c;
   int line = 0;
   FILE *fd;

   if (argc != 2)
   {
       fprintf(stderr, "Usage: %s file\n", argv[0]);
       exit(1);
   }

   fd = fopen(argv[1], "r");
   if (fd == NULL)
   {
       perror(argv[1]);
       exit(2);
   }

   initscr();
   cbreak();
   nonl();
   noecho();
   idlok(stdscr, TRUE);
   keypad(stdscr, TRUE);

   /* Read in the file */
   while ((c = getc(fd)) != EOF)
   {
       if (c == '\n')
           line++;
       if (line > LINES - 2)
           break;
       addch(c);
   }
   fclose(fd);

   move(0,0);
   refresh();
   edit();

   /* Write out the file */
   fd = fopen(argv[1], "w");
   for (l = 0; l < LINES - 1; l++)
   {
       n = len(l);
       for (i = 0; i < n; i++)
           putc(mvinch(l, i) & A_CHARTEXT, fd);
       putc('\n', fd);
   }
   fclose(fd);

   endwin();
   return 0;
}
Пример #13
0
void put_m_at(short row, short col, object *monster)
{
    monster->row = row;
    monster->col = col;
    dungeon[row][col] |= MONSTER;
    monster->trail_char = mvinch(row, col);
    (void) add_to_pack(monster, &level_monsters, 0);
    aim_monster(monster);
}
Пример #14
0
/*
 * os_scroll_area
 *
 * Scroll a rectangular area of the screen up (units > 0) or down
 * (units < 0) and fill the empty space with the current background
 * colour. Top left coordinates are (1,1). The cursor stays put.
 *
 */
void os_scroll_area (int top, int left, int bottom, int right, int units)
{
  top--; left--; bottom--; right--;

  if ((left == 0) && (right == h_screen_cols - 1)) {
    static int old_scroll_top = 0;
    static int old_scroll_bottom = 0;

    if (!((old_scroll_top == top) && (old_scroll_bottom == bottom))) {
        old_scroll_top = top; old_scroll_bottom = bottom;
        setscrreg(top, bottom);
    }
    scrollok(stdscr, TRUE);
    scrl(units);
    scrollok(stdscr, FALSE);
  } else {
    int row, col, x, y;
    chtype ch;

    getyx(stdscr, y, x);
    /* Must turn off attributes during copying.  */
    attrset(0);
    if (units > 0) {
      for (row = top; row <= bottom - units; row++)
	for (col = left; col <= right; col++) {
	  ch = mvinch(row + units, col);
	  mvaddch(row, col, ch);
	}
    } else if (units < 0) {
      for (row = bottom; row >= top - units; row--)
	for (col = left; col <= right; col++) {
	  ch = mvinch(row + units, col);
	  mvaddch(row, col, ch);
	}
    }
    /* Restore attributes.  */
    os_set_text_style(u_setup.current_text_style);
    move(y, x);
  }
  if (units > 0)
    os_erase_area(bottom - units + 2, left + 1, bottom + 1, right + 1, 0);
  else if (units < 0)
    os_erase_area(top + 1, left + 1, top - units, right + 1, 0);
}/* os_scroll_area */
Пример #15
0
int place_start_boy()
{
    int height = 0;
    while(mvinch(height,0) != 'I')
    {
        height++;
    }

    return (height - 2);
}
Пример #16
0
int
image(void)
{
 int x = 0, y = 0, c = 0, max_x = 0, max_y = 0, i = 0, j = 0;
 chtype ch = 0;
 WINDOW *img_w = NULL;

 if ( NULL != log_file ) {
     getmaxyx(stdscr, max_y, max_x);
     if ( (max_y < MIN_Y) || (max_x < MIN_X) ) {
         return (-1);
     }
     if ( NULL == (img_w = newwin(0, max_x-24, max_y-11, 13)) ) {
         beep(); return (-1);
     }
     for (;;) {
         getmaxyx(stdscr, max_y, max_x);
         if ( (max_y < MIN_Y) || (max_x < MIN_X) ) {
             delwin(img_w); return (-1);
         }
         (void)wborder(img_w, '|', '|', '-', '-', '+', '+', '+', '+');
         mvwaddstr(img_w, 1, (int)(((max_x-24)/2)-6), "PRINT SCREEN");
         mvwaddstr(img_w, 3, 2, "Press Enter to save the screen image");
         mvwaddstr(img_w, 4, 6, "in the log file.");
         mvwaddstr(img_w, 5, 2,"Press Cancel to return to the application.");
         mvwaddstr(img_w, 8, 2, "F1=Help");
         mvwaddstr(img_w, 8, (int)((max_x-24)/3), "F2=Refresh");
         mvwaddstr(img_w, 9, 2, "F10=Exit");
         mvwaddstr(img_w, 8, (int)(2*(max_x-24)/3), "F3=Cancel");
         mvwaddstr(img_w, 9, (int)((max_x-24)/3), "Enter=Do");
         wrefresh(img_w);
         for (;;) {
             c = get_key(max_y-4, 15);
             if ( (KEY_F(1) == c) || (KEY_F(10) == c) || (KEY_F(3) == c) ) {
                 delwin(img_w); return (c);
             } else if ( KEY_F(2) == c ) {
                 break;
             } else if ( KEY_ENTER == c ) {
                 (void)fprintf(log_file, "\n");
                 for ( i = 0; i < max_y; i++ ) {
                     for ( j = 0; j < max_x; j++ ) {
                         if ( isprint(ch = (A_CHARTEXT & mvinch(i, j))) ) {
                             (void)fprintf(log_file, "%c", (int)ch);
                         }
                     }
                     (void)fprintf(log_file, "\n");
                 }
                 (void)fprintf(log_file, "\n"); (void)fflush(log_file);
                 delwin(img_w); return (0);
             }
         }
     }
 }
 delwin(img_w); return (0);
}
Пример #17
0
void END_Check(int stgnum, Agent_status *agent, node_t *trees, int auto_or_mamual,Girl *Girl_status)
{
    if(mvinch(agent->Y,agent->X+1) == '*' || 
       mvinch(agent->Y,agent->X-1) == '*' ||
       mvinch(agent->Y+1,agent->X) == '*' ||
       ((mvinch(agent->Y-1,agent->X) == '*') &&( agent->Jumpflag == 1)))
    {
        agent->ENEMY_TOUCH_FLAG = 1;//あとで直す
        END(0,stgnum,trees,auto_or_mamual,agent);
    }
    else if((agent->X >= Girl_status->X))
    {
        END(1,stgnum,trees,auto_or_mamual,agent);
    }
    else if(agent->TIMES <= 0 )
    {
        END(0,stgnum,trees,auto_or_mamual,agent);
    }

}
Пример #18
0
//蛇的表示是用一个带头尾结点的双向链表来表示的,
//蛇的每一次前进,都是在链表的头部增加一个节点,在尾部删除一个节点
//如果蛇吃了一个食物,那就不用删除节点了
void showSnake()
{
    //最多30个计数周期刷新一次,随着级别增加而变快
    if(1 != tTime % (30-level))
        return;
    //判断蛇的长度有没有改变
    bool lenChange = false;
    //显示食物
    move(food.cy, food.cx);
    printw("@");
    //如果蛇碰到墙,则游戏结束
    if((COLS-1==head->next->cx && 1==dir.cx)
        || (0==head->next->cx && -1==dir.cx)
        || (LINES-1==head->next->cy && 1==dir.cy)
        || (2==head->next->cy && -1==dir.cy))
    {
        over(1);
        return;
    }
    //如果蛇头砬到自己的身体,则游戏结束
    //mvinch光标移动到特定位置并返回该位置的字符
    if('*' == mvinch(head->next->cy+dir.cy, head->next->cx+dir.cx) )
    {
        over(2);
        return;
    }
    //在头部位置插入一个节点
    insertNode(head->next->cx+dir.cx, head->next->cy+dir.cy);
    //蛇吃了一个“食物”
    if(head->next->cx==food.cx && head->next->cy==food.cy)
    {
        lenChange = true;
        length++;
        //恭喜你,通关了
        if(length >= 50)
        {
            over(3);
            return;
        }
        //重新设置食物的位置
        food.cx = rand() % COLS;
        food.cy = rand() % (LINES-2) + 2;
    }
    if(!lenChange)
    {
        move(tail->back->cy, tail->back->cx);
        printw(" ");
        //删除尾部最后一个节点
        deleteNode();
    }
    //再刚才插入的头部位置显示*符号
    move(head->next->cy, head->next->cx);
    printw("*");
}
Пример #19
0
//慣性によって動く方向が変わる
//Moving Right or Left
int moveRoL(Agent_status *agent){
    int i;
    for(i=0;i<=abs(agent->INTERTIA);i++){
        if(agent->INTERTIA > 0){//右へ
            //            if(mvinch(agent->Y,agent->X+1) != 'I')
                if((mvinch(agent->Y,agent->X+1) != 'I') && ( mvinch(agent->Y,agent->X+1) != '*'))
                {
                agent->X += 1;
            }

        }else if(agent->INTERTIA < 0){//左へ
            //            if(mvinch(agent->Y,agent->X-1) != 'I')
                if((mvinch(agent->Y,agent->X-1) != 'I') && (mvinch(agent->Y,agent->X-1) != '*'))
            {
                agent->X -= 1;
            }
        }
    }
    return 0;
}
Пример #20
0
static void collision(ball *b){
    int cur=mvinch(b->y,b->x);
    /* mvprintw(10,10,"%d",cur); */
    switch(cur&A_CHARTEXT){
        case WALL:quit=1;break;
        case LRWALL:b->direction_x=-1;b->direction_y=0;break;
        case RRWALL:b->direction_x=1;b->direction_y=0;break;
        case URWALL:b->direction_x=0;b->direction_y=-1;break;
        case DRWALL:b->direction_x=0;b->direction_y=1;break;
        default:break;
    }
}
Пример #21
0
static inline void drawball(ball *b){
    b->oldico=(mvinch(b->y,b->x))&A_CHARTEXT;
    switch(b->oldico){
        case WALL:quit=1;break;
        case LRWALL:b->direction_x=-1;b->direction_y=0;break;
        case RRWALL:b->direction_x=1;b->direction_y=0;break;
        case URWALL:b->direction_x=0;b->direction_y=-1;break;
        case DRWALL:b->direction_x=0;b->direction_y=1;break;
        default:break;
    }
    mvaddch(b->y,b->x,b->ico);
}
Пример #22
0
/*
takes in a 2D array of char, allows the user to navigate it with wasd.
*/
void BuildMap (char map[22][80]) {
	char in = 'a';
	char put = 'a';
	int y;
	int x;

	while(in != 'q' && in != 'Q') {
		getyx(stdscr, y, x);
		in = getch();
		/*move cursor according to user input*/
		switch(in) {
			case 'w':
				move(y - 1, x);
				break;
			case 'a':
				move(y, x - 1);
				break;
			case 's':
				move(y + 1, x);
				break;
			case 'd':
				move(y, x + 1);
				break;
			case 'e':
				/*if the user selected 'e', archive the character their cursor is on.*/
				if((char)mvinch(y, x) == '+' || (char)mvinch(y, x) == 'B' || (char)mvinch(y, x) == 'Y' || (char)mvinch(y, x) == 'S' || (char)mvinch(y, x) == 'o' || (char)mvinch(y, x) == 'O')
					put = (char)mvinch(y, x);
				break;
			case 'r':
				/*if the user selected 'r', place the archived character where their cursor is.*/
				if((char)mvinch(y, x) == '.') {
					mvaddch(y, x, put);
					map[y][x] = put;
				}
				move(y, x);
				break;
		}
		refresh();
	}
}
Пример #23
0
CursWin::CursWin(int ulr, int ulc, int lrr, int lrc, bool pop) {
    if (!numWindows) {
        WINDOW* newWin;
        newWin = initscr();
        cbreak();
        refresh();
    }
    upperLeftRow = ulr;
    upperLeftCol = ulc;
    lowerRightRow = lrr;
    lowerRightCol = lrc;
    isPopUp = pop;
    if (isPopUp) {
        int ySize = (lrr - ulr) + 1, xSize = (lrc - ulc) + 1;
        restore = new char*[ySize];
        for (int r = 0; r < ySize; r++) {
            restore[r] = new char[xSize];
            for (int c = 0; c < xSize; c++) {
                restore[r][c] = mvinch(ulr+r, ulc+c);
            }
        }
        DrawBoundingBox('#','#','#');
        ClearWin();
    }
    else {
        restore = NULL;
        DrawBoundingBox('-','|','+');
    }
    writeEnabled = true;
    scrolling = true;
    onScreen = true;
    curRowPos = curColPos = 0;
    headerWidth = footerWidth = 0;
    maxRowPos = lowerRightRow - (upperLeftRow+2);
    maxColPos = lowerRightCol - (upperLeftCol+2);
    sv.expectingStreamParam = false;
    sv.precision = 2;
    sv.left_justified = true;
    sv.last = cflush;
    sv.field_enabled = false;
    sv.paramNum = 1;
    sv.invalid_input = false;
    sv.immErrorHandling = false;
    sv.min_filter = sv.max_filter = sv.fail_value = 0.0;
    sv.force_range = sv.min_active = sv.max_active = false;
    sv.filter_active = 0;
    CursErrorOut = NULL;
    for (int i = 0; i < 1000; i++) {
        InputStream[i] = '\0';
    }
    numWindows++;
}
Пример #24
0
void
movefunc(int ch1, int *y, int *x)
{
	mvaddch(*y,*x,46);

	if ((ch1 == KEY_UP || ch1 == 259) && mvinch(*y-1,*x) == 46)
	{
		(*y)--;
	}
	else if ((ch1 == KEY_DOWN || ch1 == 258) && mvinch(*y+1,*x) == 46)
	{
		(*y)++;
	}
	else if ((ch1 == KEY_LEFT || ch1 == 260) && mvinch(*y,*x-1) == 46)
	{
		(*x)--;
	}
	else if ((ch1 == KEY_RIGHT || ch1 == 261) && mvinch(*y, *x+1) == 46)
	{
		(*x)++;
	}
}
Пример #25
0
static void curses_copy(unsigned x1, unsigned y1, unsigned x2, unsigned y2,
          unsigned nx, unsigned ny)
{
    /* Cant figure this out.  Be evil. */
    int x, y;

    for (y=0; y<=y2-y1; y++) {
	for (x=0; x<=x2-x1; x++) {
	    int at = mvinch(y1+y, x1+x);
	    mvaddch(ny+y, nx+x, at);
	}
    }
}
Пример #26
0
//センサーH_右下
int sensor_H(Agent_status *strAGENT)
{
    int flag = 0;
    if(mvinch(strAGENT->Y+1,strAGENT->X+1) != ' ') 
    {
        flag = 1;
    }
    else
    {
        flag = 0;
    }

    return flag;
}
Пример #27
0
void Girl_search(Girl *Girl_status)
{
    int i=0,j=0;
    while(1)
    {
        if(mvinch(i,0)=='I')
        {
            Girl_status->Y = i-1;
            break;
        }
        i++;
    }

    while(1)
    {
        if(mvinch(Girl_status->Y,j)=='L')
        {
            Girl_status->X = j;
            break;
        }
        j++;
    }
}
Пример #28
0
void
fight(boolean to_the_death)
{
	short ch, c, d;
	short row, col;
	boolean first_miss = 1;
	short possible_damage;
	object *monster;

	while (!is_direction(ch = rgetchar(), &d)) {
		sound_bell();
		if (first_miss) {
			message("direction?", 0);
			first_miss = 0;
		}
	}
	check_message();
	if (ch == CANCEL) {
		return;
	}
	row = rogue.row; col = rogue.col;
	get_dir_rc(d, &row, &col, 0);

	c = mvinch(row, col);
	if (((c < 'A') || (c > 'Z')) ||
		(!can_move(rogue.row, rogue.col, row, col))) {
		message("I see no monster there", 0);
		return;
	}
	if (!(fight_monster = object_at(&level_monsters, row, col))) {
		return;
	}
	if (!(fight_monster->m_flags & STATIONARY)) {
		possible_damage = ((get_damage(fight_monster->m_damage, 0) * 2) / 3);
	} else {
		possible_damage = fight_monster->stationary_damage - 1;
	}
	while (fight_monster) {
		one_move_rogue(ch, 0);
		if (((!to_the_death) && (rogue.hp_current <= possible_damage)) ||
			interrupted || (!(dungeon[row][col] & MONSTER))) {
			fight_monster = NULL;
		} else {
			monster = object_at(&level_monsters, row, col);
			if (monster != fight_monster) {
				fight_monster = NULL;
			}
		}
	}
}
Пример #29
0
//蛇的表示是用一个带头尾结点的双向链表来表示的,
//蛇的每一次前进,都是在链表的头部增加一个节点,在尾部删除一个节点
//如果蛇吃了一个食物,那就不用删除节点了
void showSnake()
{
    if(1 != tTime % (30-level))
        return;
    //判断蛇的长度有没有改变
    bool lenChange = false;
    //显示食物
    move(food.cy, food.cx);
    printw("@");
    //如果蛇碰到墙,则游戏结束
    if((COLS-1==head->next->cx && 1==dir.cx)
        || (0==head->next->cx && -1==dir.cx)
        || (LINES-1==head->next->cy && 1==dir.cy)
        || (2==head->next->cy && -1==dir.cy))
    {
        over(1);
        return;
    }
    //如果蛇头砬到自己的身体,则游戏结束
    if('*' == mvinch(head->next->cy+dir.cy, head->next->cx+dir.cx) )
    {
        over(2);
        return;
    }
    insertNode(head->next->cx+dir.cx, head->next->cy+dir.cy);
    //蛇吃了一个“食物”
    if(head->next->cx==food.cx && head->next->cy==food.cy)
    {
        lenChange = true;
        length++;
        //恭喜你,通关了
        if(length >= 50)
        {
            over(3);
            return;
        }
        //重新设置食物的位置
        food.cx = rand() % COLS;
        food.cy = rand() % (LINES-2) + 2;
    }
    if(!lenChange)
    {
        move(tail->back->cy, tail->back->cx);
        printw(" ");
        deleteNode();
    }
    move(head->next->cy, head->next->cx);
    printw("*");
}
Пример #30
0
char get_screen_char( int x, int y ) {
    if ( override_screen == NULL ) {
        return mvinch( y, x ) & 0xff;
    }

    int w = override_screen->width;
    int h = override_screen->height;

    if ( x >= 0 && x < w && y >= 0 && y < h ) {
        char * scr = override_screen->buffer;
        return scr[x + y * w];
    }
    else {
        return 0;
    }
}