SetupBBS 板


游戏规则写在游戏画面中了 :) == src/maple/menu.c == + "bin/seven.so:seven_main", PERM_VALID, - M_XMODE, + "Seven 接龙游戏", == src/so 下新增下面那只程式 == /*-------------------------------------------------------*/ /* so/seven.c ( YZU WindTopBBS Ver 3.00 ) */ /*-------------------------------------------------------*/ /* author : [email protected] */ /* target : 接龙游戏 */ /* create : 2001/01/12 */ /*-------------------------------------------------------*/ #include "bbs.h" #define DO_LOG int cards[52]; int seven[7]; int points[7]; /*************************************** 画出牌 ***************************************/ void draw_card(card,x,y) int card; int x; int y; { char *flower[] ={"C","D","H","S"}; char *number[] ={"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; move(x ,y);prints("╭───╮"); move(x+1,y);prints("│%s  │",(card<0)?" ":number[card%13]); move(x+2,y);prints("│%s  │",(card<0)?" ":flower[card%4]); move(x+3,y);prints("│   │"); move(x+4,y);prints("│   │"); move(x+5,y);prints("╰───╯"); return ; } /*************************************** 游戏说明 ***************************************/ int draw_explain(void) { int x=4; clear(); vs_head("接龙游戏", str_site); move(x+ 0,10);prints("【游戏说明】"); move(x+ 2,15);prints("(1) 在萤幕上方为牌墩,可以利用←、→或 j , k 切换。"); move(x+ 4,15);prints("(2) 在萤幕左下方为持牌 , 可以利用 c 切换。"); move(x+ 6,15);prints("(3) 当牌墩的牌是持牌的下一张或上一张,即可利用 Enter 吃牌。"); move(x+ 7,15);prints(" (只看点数,不看花色)"); move(x+ 9,15);prints("(4) 当牌墩的牌都吃完,及游戏获胜。"); move(x+11,15);prints("(5) 当持牌切换完且尚未吃完牌墩的牌,即游戏失败。"); move(x+13,15);prints("(6) 此游戏版权属於 [email protected]"); vmsg(NULL); } /*************************************** 画出游戏牌的配置 ***************************************/ void draw_screen(void) { int i,j; clear(); vs_head("接龙游戏", str_site); for(i=0;i<7;i++) for(j=0;j<i+1;j++) { draw_card((i==j)?cards[i]:-1,4+j,5+i*10); } } /*************************************** 画出游标 ***************************************/ void draw_cursor(location,mode) int location; int mode; { move(8+seven[location],9+location*10); prints("%s",(mode==0)?" ":"●"); } /*************************************** 清除萤幕上的牌 ***************************************/ void clear_card(location) int location; { move(9+seven[location],5+location*10); prints("     "); } /*************************************** 游戏参数初始化 ***************************************/ int init(void) { int i,num,tmp; for(i=0;i<52;i++) cards[i] = i; srand(time(0)); for(i=0;i<52;i++) { num = cards[i] ; tmp = rand() % 52 ; cards[i] = cards[tmp] ; cards[tmp] = num; } for(i=0;i<7;i++) { seven[i] = i; points[i] = cards[i] ; } return 0; } /*************************************** 判断游戏是否结束 ***************************************/ int gameover(void) { int i; for(i=0;i<7;i++) if(seven[i] != -1 ) return 0; return 1; } /*************************************** 游戏主程式 ***************************************/ int play(void) { int location = 0; int c,i; int now_card=7; int have_card=22; int point; draw_screen(); draw_cursor(location,1); point = cards[now_card] ; draw_card(cards[now_card++],14,5); move(19,40); prints("你还有 %2d 机会可以换牌",have_card); move(18,10); outz("\033[1;37;42m【操作说明】 [j]左移 [k]右移 [enter]吃牌 [c]换牌 [q]离开 \033[m"); do { c = vkey(); switch ( c ) { case 'c' : if(have_card == 0) return -1; have_card--; move(19,40); prints("你还有 %2d 机会可以换牌",have_card); point = cards[now_card]; draw_card(cards[now_card++],14,5); break; case 'k' : case KEY_RIGHT : draw_cursor(location,0); do { location = (location+1) % 7; }while(seven[location] == -1); draw_cursor(location,1); break; case 'j' : case KEY_LEFT : draw_cursor(location,0); do { location = (location==0)?6:location-1; }while(seven[location] == -1); draw_cursor(location,1); break; case '\n' : case ' ' : if(points[location]%13-point%13 == 1 || points[location]%13-point%13 == -1 || points[location]%13-point%13 == 12 || points[location]%13-point%13 == -12) { point = points[location]; draw_card(point,14,5); clear_card(location); draw_cursor(location,0); seven[location]--; if(seven[location]>=0) { points[location] = cards[now_card]; draw_card(cards[now_card++],4+seven[location],5+location*10); draw_cursor(location,1); } else { for(i=0;i<5;i++) { move(4+i,5+location*10); prints("     "); } if( gameover() == 1) return have_card; do { location = (location+1) % 7; }while(seven[location] == -1); draw_cursor(location,1); } } break; case 'q' : return -2 ; } }while(1); return 0; } int seven_main(void) { int tmp; draw_explain(); do { init(); clear(); tmp = play(); if(tmp>=0){ vmsg("恭喜你过关啦 !!"); } else if(tmp==-1){ vmsg("挑战失败 !!"); } else if(tmp==-2) { vmsg("下次再来玩唷 !!"); return 0; } if(vans("是否要继续? [y/N]") != 'y') break; }while(1); return 0; } -- ※ Origin: 元智大学 风之塔 <bbs.yzu.edu.tw> ※ From : bbs.yzu.edu.tw







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草
伺服器连线错误,造成您的不便还请多多包涵!
「赞助商连结」






like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP