Exemplo n.º 1
0
/* 左键 */
int windig(int x, int y) {
    int dx, dy;
    if(x< 1|| x> 30|| y< 1|| y> 16) return;
    if(o[x][y]||m[x][y]) return;
    o[x][y]=1;
    winsh(x, y);
    if(a[x][y]) {
	show_mines();
         gameover=1;
         return;
    }
    if(num_mine_beside(x, y)==0) {
        for(dx=x-1;dx<=x+1;dx++)
        for(dy=y-1;dy<=y+1;dy++)
            windig(dx, dy);
    }
}
Exemplo n.º 2
0
int winloop()
{
    int x, y, c, marked, t0, inited;
    x= 10;
    y= 8;
    inited= 0; 
    marked= 0; 
    t0=time(0);
    steps=0;
    while(1) {
        c= igetkey();
			//system("echo start_winloop_igetkey >> /home/bbs/stiger.test");
		steps++;
		if(c=='q' || c==Ctrl('C')) return 0;
        if((c==KEY_UP||c=='k')&&y>1) y--;
        if((c==KEY_DOWN||c=='j')&&y<16) y++;
        if((c==KEY_LEFT||c=='h')&&x>1) x--;
        if((c==KEY_RIGHT||c=='l')&&x<30) x++;
        move(20,0);
        prints("й╠╪Д: %d ", time(0)-t0);
        move(21,0);
        prints("вЬ╠Й: %3d, %3d", x, y);
        move(y-1,x*2-2);
//modified by stiger,2001,6,12,╦дуЩmarkedмЁ╪ф╣д╢МнС
        if(ganyingshi)
        {
        	marknum=o[x-1][y-1]+o[x-1][y]+o[x-1][y+1]+o[x][y-1]+o[x][y+1]+o[x+1][y-1]+o[x+1][y]+o[x+1][y+1];
        	if((m[x][y]!=1)&&(num_mine_beside(x, y)==8-marknum)) {
        	    	if(o[x-1][y-1]!=1) { if(!m[x-1][y-1]) {m[x-1][y-1]=1;   marked++; }  winsh(x-1,y-1);}     	
        		if(o[x-1][y]!=1) { if(!m[x-1][y]) {m[x-1][y]=1;   marked++; } winsh(x-1,y);}     	
        		if(o[x-1][y+1]!=1) { if(!m[x-1][y+1]) {m[x-1][y+1]=1;   marked++;}  winsh(x-1,y+1);}     	
        		if(o[x][y-1]!=1) { if(!m[x][y-1]) {m[x][y-1]=1;   marked++; } winsh(x,y-1);}     	
        		if(o[x][y+1]!=1) { if(!m[x][y+1]) {m[x][y+1]=1;   marked++;}  winsh(x,y+1);}
        		if(o[x+1][y-1]!=1) { if(!m[x+1][y-1]) {m[x+1][y-1]=1;   marked++;}  winsh(x+1,y-1);}     	
        		if(o[x+1][y]!=1) { if(!m[x+1][y]) {m[x+1][y]=1;   marked++;}  winsh(x+1,y);}     	
         		if(o[x+1][y+1]!=1) { if(!m[x+1][y+1]) {m[x+1][y+1]=1;   marked++;}  winsh(x+1,y+1);}     	
        	}
        	if(num_mine_beside(x, y)==num_mark_beside(x, y)) dblclick(x,y); 
        }
//add by stiger,2001,6,12,╦дуЩmarkedотй╬╣днйлБ
        move(20,30);
        prints("╠Й╪г: %d ", marked);
//add end
        if(c=='H') winhelp();
        if(c=='d'|| c=='D') winrefresh();
        if(c=='f'|| c=='F'){
             if(!inited) {
                  wininit(x, y);
                  inited= 1;
             } 
             dig(x, y);      
        } 
        if((c==83|| c==115)&&!o[x][y]) {
             if(m[x][y]){
                  m[x][y]=0;
                  marked--;
             } else {
                  m[x][y]=1;
                  marked++;
             }
             winsh(x, y);
//add by stiger,2001,6,12
        	move(20,30);
        	prints("╠Й╪г: %d ", marked);
//add end
        }
        if(checkwin()==1) {
            /*add by stiger*/
            stiger=steps*1.0/(time(0)-t0);
            move(22,0);
            prints("вё╨ьдЦё║дЦЁи╧╕акё║ф╫╬Ыц©цК%lf╡╫",stiger);
            gameover= 0;
 	    	win_checkrec(time(0)-t0);/* added by soff ╫Ьппеепп╪Л╡И */
            return 1;
        }
        if(gameover) {
            move(22,0);
            prints("╨эре╨╤ё╛дЦй╖╟эак... тыю╢р╩╢н╟иё║                                 ");
            gameover= 0;
            return 1;
        }
        move(y-1,x*2-2);
        refresh();
    }
	return 1;
}
Exemplo n.º 3
0
void
winloop()
{
	int x, y, c, marked, t0, inited;
	char buf[100];
	x = 10;
	y = 8;
	inited = 0;
	marked = 0;
	clearbuf();
	t0 = time(0);
	while (1) {
		c = egetch();
		if (c == 257 && y > 1)
			y--;
		if (c == 258 && y < 16)
			y++;
		if (c == 260 && x > 1)
			x--;
		if (c == 259 && x < 30)
			x++;
		move(0, 20);
		sprintf(buf, "ʱ¼ä: %d ", (int) (time(0) - t0));
		prints(buf);
		move(40, 20);
		sprintf(buf, "񈬀: %d ", marked);
		prints(buf);
		move(0, 22);
		sprintf(buf, "×ø±ê: %3d, %3d", x, y);
		prints(buf);
		move(x * 2 - 2, y - 1);
		if (c == 'h' || c == 'H')
			winhelp();
		if (c == 'd' || c == 'D')
			winrefresh();
		if (c == 'a' || c == 'A') {
			if (!inited) {
				wininit(x, y);
				inited = 1;
			}
			dig(x, y);
		}
		if ((c == 83 || c == 115) && !o[x][y]) {
			if (m[x][y]) {
				m[x][y] = 0;
				marked--;
			} else {
				m[x][y] = 1;
				marked++;
			}
			winsh(x, y);
		}
		if (checkwin() == 1) {
			move(0, 22);
			prints("×£ºØÄ㣡Äã³É¹¦ÁË£¡                    ");
			{
				char buf[100];
				sprintf(buf, "finished in %d s.",
					(int) (time(0) - t0));
				win_checkrec(time(0) - t0);
				winminelog(buf);
			}
			gameover = 0;
			return;
		}
		if (gameover) {
			move(0, 22);
			prints("ºÜÒź¶£¬Äãʧ°ÜÁË... ÔÙÀ´Ò»´Î°É£¡    ");
			{
				char buf[100];
				sprintf(buf, "failed in %d s.",
					(int) (time(0) - t0));
				winminelog(buf);
			}
			gameover = 0;
			return;
		}
		move(x * 2 - 2, y - 1);
		refresh();
	}
}
Exemplo n.º 4
0
int winloop()
{
    int x, y, c, marked, t0, inited;
    char buf[100];
    x= 10;
    y= 8;
    inited= 0; 
    marked= 0; 
    clearbuf();
    t0= time(0);
    while(1) {
        c= egetch();
        if((c==257||c=='k')&&y>1) y--;
        if((c==258||c=='j')&&y<16) y++;
        if((c==260||c=='h')&&x>1) x--;
        if((c==259||c=='l')&&x<30) x++;
        move(0, 20);
        //% sprintf(buf, "时间: %ld ", time(0)-t0);
        sprintf(buf, "\xca\xb1\xbc\xe4: %ld ", time(0)-t0);
        prints(buf);
        move(40, 20);
        //% sprintf(buf, "标记: %d ", marked);
        sprintf(buf, "\xb1\xea\xbc\xc7: %d ", marked);
        prints(buf);
        move(0, 21);
        //% sprintf(buf, "坐标: %3d, %3d", x, y);
        sprintf(buf, "\xd7\xf8\xb1\xea: %3d, %3d", x, y);
        prints(buf);
        move(x*2-2, y-1);
        if(c=='H') winhelp();
        if(c=='d'|| c=='D') winrefresh();
        if(c=='f'|| c=='F'){
             if(!inited) {
                  wininit(x, y);
                  inited= 1;
             } 
             dig(x, y);      
        } 
        if((c==83|| c==115)&&!o[x][y]) {
             if(m[x][y]){
                  m[x][y]=0;
                  marked--;
             } else {
                  m[x][y]=1;
                  marked++;
             }
             winsh(x, y);
        }
        if(checkwin()==1) {
            move(0, 22);
            //% prints("祝贺你!你成功了!                    ");
            prints("\xd7\xa3\xba\xd8\xc4\xe3\xa3\xa1\xc4\xe3\xb3\xc9\xb9\xa6\xc1\xcb\xa3\xa1                    ");
            {  char buf[100];
               sprintf(buf, "finished in %ld s.", time(0)-t0);
               syslog(buf);
            }
            gameover= 0;
 	    win_checkrec(time(0)-t0);/* added by soff 进行排行检查 */
            return;
        }
        if(gameover) {
            move(0, 22);
            //% prints("很遗憾,你失败了... 再来一次吧!                                 ");
            prints("\xba\xdc\xd2\xc5\xba\xb6\xa3\xac\xc4\xe3\xca\xa7\xb0\xdc\xc1\xcb... \xd4\xd9\xc0\xb4\xd2\xbb\xb4\xce\xb0\xc9\xa3\xa1                                 ");
            {  char buf[100];
               sprintf(buf, "failed in %ld s.", time(0)-t0);
               syslog(buf);
            }
            gameover= 0;
            return;
        }
        move(x*2-2, y-1);
        refresh();
    }
}