int winmine() { int x,y; win_showrec(); clear(); refresh(); while(1) { totallei=0;//add by stiger stiger=0;//add by stiger steps=0;//add by stiger opened=0; clear(); for (x=0;x<=31;x++) for (y=0;y<=17;y++) { a[x][y]= 0; m[x][y]= 0; f[x][y]= 0;//add by stiger // o[x][y]= 0; // if(x==0||x==31||y==0||y==17) o[x][y]= 1; else o[x][y]=0; } winrefresh(); if(winloop()==0) break; pressanykey(); } return 0; }
void NWindowEdit::setSize (int w, int h) { ew = w; eh = h; wresize (window, eh, ew); winrefresh (); }
int winhelp() { screen_clear(); //% prints("==欢迎来玩键盘扫雷游戏== (程序由 nju BBS 站长 zhch 设计)\r\n---------------------------------\\r\n\r\n"); prints("==\xbb\xb6\xd3\xad\xc0\xb4\xcd\xe6\xbc\xfc\xc5\xcc\xc9\xa8\xc0\xd7\xd3\xce\xcf\xb7== (\xb3\xcc\xd0\xf2\xd3\xc9 nju BBS \xd5\xbe\xb3\xa4 zhch \xc9\xe8\xbc\xc6)\r\n---------------------------------\\r\n\r\n"); //% prints("玩法很简单,和[1;34mwindows[m下的鼠标扫雷差不多.\r\n"); prints("\xcd\xe6\xb7\xa8\xba\xdc\xbc\xf2\xb5\xa5\xa3\xac\xba\xcd[1;34mwindows[m\xcf\xc2\xb5\xc4\xca\xf3\xb1\xea\xc9\xa8\xc0\xd7\xb2\xee\xb2\xbb\xb6\xe0.\r\n"); //% prints(" '[1;32mF[m'键的作用相当于鼠标的左键及双击的作用, 程序根据你点击的位置\r\n"); prints(" '[1;32mF[m'\xbc\xfc\xb5\xc4\xd7\xf7\xd3\xc3\xcf\xe0\xb5\xb1\xd3\xda\xca\xf3\xb1\xea\xb5\xc4\xd7\xf3\xbc\xfc\xbc\xb0\xcb\xab\xbb\xf7\xb5\xc4\xd7\xf7\xd3\xc3\xa3\xac \xb3\xcc\xd0\xf2\xb8\xf9\xbe\xdd\xc4\xe3\xb5\xe3\xbb\xf7\xb5\xc4\xce\xbb\xd6\xc3\r\n"); //% prints(" 自动判断要进行哪种操作。\r\n"); prints(" \xd7\xd4\xb6\xaf\xc5\xd0\xb6\xcf\xd2\xaa\xbd\xf8\xd0\xd0\xc4\xc4\xd6\xd6\xb2\xd9\xd7\xf7\xa1\xa3\r\n"); //% prints(" '[1;32mS[m'键则相当于鼠标右键的功能, 可用来标雷.\r\n"); prints(" '[1;32mS[m'\xbc\xfc\xd4\xf2\xcf\xe0\xb5\xb1\xd3\xda\xca\xf3\xb1\xea\xd3\xd2\xbc\xfc\xb5\xc4\xb9\xa6\xc4\xdc, \xbf\xc9\xd3\xc3\xc0\xb4\xb1\xea\xc0\xd7.\r\n"); //% prints(" '[1;32mH[m'键用来显示本帮助信息.\r\n"); prints(" '[1;32mH[m'\xbc\xfc\xd3\xc3\xc0\xb4\xcf\xd4\xca\xbe\xb1\xbe\xb0\xef\xd6\xfa\xd0\xc5\xcf\xa2.\r\n"); //% prints(" '[1;32mQ[m'键退出游戏.\r\n"); prints(" '[1;32mQ[m'\xbc\xfc\xcd\xcb\xb3\xf6\xd3\xce\xcf\xb7.\r\n"); //% prints(" 当屏幕乱掉时,可用'[1;32mD[m'可用来刷新屏幕。\r\n"); prints(" \xb5\xb1\xc6\xc1\xc4\xbb\xc2\xd2\xb5\xf4\xca\xb1\xa3\xac\xbf\xc9\xd3\xc3'[1;32mD[m'\xbf\xc9\xd3\xc3\xc0\xb4\xcb\xa2\xd0\xc2\xc6\xc1\xc4\xbb\xa1\xa3\r\n"); //% prints("建议用[1;32mNetterm[m来玩(当然njuterm也可以,:)),[1;32mtelnet[m效果不是太好\r\n"); prints("\xbd\xa8\xd2\xe9\xd3\xc3[1;32mNetterm[m\xc0\xb4\xcd\xe6(\xb5\xb1\xc8\xbbnjuterm\xd2\xb2\xbf\xc9\xd2\xd4,:)),[1;32mtelnet[m\xd0\xa7\xb9\xfb\xb2\xbb\xca\xc7\xcc\xab\xba\xc3\r\n"); //% prints("第一次点击一定会开一片,很舒服吧。\r\n"); prints("\xb5\xda\xd2\xbb\xb4\xce\xb5\xe3\xbb\xf7\xd2\xbb\xb6\xa8\xbb\xe1\xbf\xaa\xd2\xbb\xc6\xac\xa3\xac\xba\xdc\xca\xe6\xb7\xfe\xb0\xc9\xa1\xa3\r\n"); //% prints("熟练后,速度还是很快的,几乎可以达到鼠标扫雷的速度.\r\n"); prints("\xca\xec\xc1\xb7\xba\xf3\xa3\xac\xcb\xd9\xb6\xc8\xbb\xb9\xca\xc7\xba\xdc\xbf\xec\xb5\xc4\xa3\xac\xbc\xb8\xba\xf5\xbf\xc9\xd2\xd4\xb4\xef\xb5\xbd\xca\xf3\xb1\xea\xc9\xa8\xc0\xd7\xb5\xc4\xcb\xd9\xb6\xc8.\r\n"); pressanykey(); winrefresh(); }
int winhelp() { clear(); prints("==╩╤с╜ю╢мФ╪Эели╗ювсно╥== \r\n---------------------------------\r\n\r\n"); prints("мФ╥╗╨э╪Р╣╔ё╛╨м[1;34mwindows[mоб╣дйС╠Йи╗юв╡Н╡╩╤Ю.\r\n"); prints(" '[1;32mF[m'╪Э╣двВсцоЮ╣╠сзйС╠Й╣двС╪Э╪╟к╚╩В╣двВсцё╛ ЁлпР╦Ы╬щдЦ╣Ц╩В╣дн╩жц\r\n"); prints(" вт╤╞еп╤ор╙╫Ьппдджж╡ывВ║ё\r\n"); prints(" '[1;32mS[m'╪ЭтРоЮ╣╠сзйС╠Йср╪Э╣д╧╕дэ, ©исцю╢╠Йюв.\r\n"); prints(" '[1;32mH[m'╪Эсцю╢отй╬╠╬╟ОжЗпео╒.\r\n"); prints(" '[1;32mQ[m'╪ЭмкЁЖсно╥.\r\n"); prints(" ╣╠фад╩бр╣Тй╠ё╛©исц'[1;32mD[m'©исцю╢к╒пбфад╩║ё\r\n"); prints("╣зр╩╢н╣Ц╩Вр╩╤╗╩А©╙р╩ф╛ё╛╨эйФ╥Ч╟и║ё\r\n"); prints("йЛа╥╨Сё╛кы╤х╩╧йг╨э©Л╣дё╛╪╦╨У©ирт╢О╣╫йС╠Йи╗юв╣дкы╤х.\r\n"); pressanykey(); winrefresh(); return 0; }
int winmine() { int x,y; win_showrec(); screen_clear(); refresh(); while(1) { screen_clear(); for (x=0;x<=31;x++) for (y=0;y<=17;y++) { a[x][y]= 0; m[x][y]= 0; o[x][y]= 0; } winrefresh(); winloop(); pressanykey(); } }
void winhelp() { clear(); prints ("==»¶ÓÀ´[1;35m" MY_BBS_NAME "[mÍæ¼üÅÌɨÀ×ÓÎÏ·==\r\n---------------------------------\\r\n\r\n"); prints("Íæ·¨ºÜ¼òµ¥£¬ºÍ[1;34mwindows[mϵÄÊó±êɨÀײ¶à.\r\n"); prints (" '[1;32mA[m'¼üµÄ×÷ÓÃÏ൱ÓÚÊó±êµÄ×ó¼ü¼°Ë«»÷µÄ×÷Ó㬠³ÌÐò¸ù¾ÝÄãµã»÷µÄλÖÃ\r\n"); prints(" ×Ô¶¯ÅжÏÒª½øÐÐÄÄÖÖ²Ù×÷¡£\r\n"); prints(" '[1;32mS[m'¼üÔòÏ൱ÓÚÊó±êÓÒ¼üµÄ¹¦ÄÜ, ¿ÉÓÃÀ´±êÀ×.\r\n"); prints(" '[1;32mH[m'¼üÓÃÀ´ÏÔʾ±¾°ïÖúÐÅÏ¢.\r\n"); prints(" '[1;32mQ[m'¼üÍ˳öÓÎÏ·.\r\n"); prints(" µ±ÆÁÄ»ÂÒµôʱ£¬¿ÉÓÃ'[1;32mD[m'¿ÉÓÃÀ´Ë¢ÐÂÆÁÄ»¡£\r\n"); prints ("½¨ÒéÓÃ[1;32mNetterm[mÀ´Íæ(µ±È»njutermÒ²¿ÉÒÔ,:)),[1;32mtelnet[mЧ¹û²»ÊÇÌ«ºÃ\r\n"); prints("µÚÒ»´Îµã»÷Ò»¶¨»á¿ªÒ»Æ¬£¬ºÜÊæ·þ°É¡£\r\n"); prints("ÊìÁ·ºó£¬ËٶȻ¹ÊǺܿìµÄ£¬¼¸ºõ¿ÉÒÔ´ïµ½Êó±êɨÀ×µÄËÙ¶È.\r\n"); pressanykey(); winrefresh(); }
void winmine() { int x, y; win_showrec(); clear(); prints("Enable ANSI color?[Y/N]"); refresh(); if (strchr("Nn", egetch())) colorful = 0; while (1) { clear(); for (x = 0; x <= 31; x++) for (y = 0; y <= 17; y++) { a[x][y] = 0; m[x][y] = 0; o[x][y] = 0; } winrefresh(); winloop(); pressanykey(); } }
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; }
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(); } }
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(); } }