【Java精品源码栏目提醒】:以下是网学会员为您推荐的Java精品源码-斗地主C语言源代码(草版) - 其它资料,希望本篇文章对您学习有所帮助。
斗地主 C 语言程序模仿版,不完善。
。
。
求完善并分享。
。
。
。
/////////////////////////////////////////////////////////////////////////////////////////////////////////////目前还存在的一些问题:1.玩家不能出连的三代;2.电脑一次只能出一张牌;3.电脑2不能作为地主,而且电脑2现在不能把牌全部出完,我估计是在循环是调用指针时候空指针没有处理好;4.玩家不能自主的选择pass. Q5.图形这次做的很成功但是当时做动态选择牌的时候失败了,否则效果应该与 Q 斗地主一样的。
以上问题由于时间问题没有进一步改进。
希望同道中人完善,交流。
/////////////////////////////////////////////////////////////////////////////////////////////////////////////include ltgraphics.hgtinclude ltstdlib.hgtinclude ltstdio.hgtinclude ltconio.hgtinclude ltmalloc.hgtinclude ltbios.hgtdefine UP 18432 /向上的键盘输入标志/define DOWN 20480 /向下的键盘输入标志/define LEFT 19200 /向左的键盘输入标志/define RIGHT 19712 /向右的键盘输入标志/int bkcol x yint a54int b54int flag20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 / flagi 1表示第i张牌还没有出 flagi 0表示这张牌这次之前就出出去了 flagi -1表示这张牌在本次中出出去了 /char card_value26 3 0 4 0 5 0 6 0 7 0 8 0 9 0 0 0 J 0 Q 0 K 0 A 0 2 0/加一个0是为了后面以字符串格式输出/struct card_node s1 NULL s2 NULLstruct card_node com1struct card_node com2struct card_node int kind int num char card struct card_node nextcard54void first_look settextjustifyCENTER_TEXT CENTER_TEXT cleardevice x getmaxx / 2 y getmaxy / 2 setcolor RED settextstyle GOTHIC_FONT 0 8 outtextxy x y - 70 quotLord Cardquot settextstyle 3 0 1 outtextxy x 110 y 40 quotProduced By Li Chaoquot outtextxy x 110 y 80 quotVersion 1.00quot getch void table int x1 int y1 settextjustifyCENTER_TEXT CENTER_TEXT bkcol BLACK /MAGENTA/ cleardevice setbkcolorbkcol setfillstyle SOLID_FILL LIGHTRED bar x1 - 140 y1 - 45 x1 136 y1 40 setcolor WHITE rectangle x1 - 141 y1 - 46 x1 137 y1 41 moveto x1 y1 - 8 settextstyle GOTHIC_FONT 0 6 outtext quotLord Cardquotvoid delete_table int x1 int y1 setfillstyle SOLID_FILL BLACK bar x1 - 141 y1 - 46 x1 137 y1 41void operation int t settextstyle 3 0 2 switch t case 1: setcolor RED outtextxy x - 10 20 quotSTARTquot setcolor WHITE outtextxy x - 10 50 quotABOUT PRODUCERquot outtextxy x - 10 80 quotEXITquot break case 2: setcolor WHITE outtextxy x - 10 20 quotSTARTquot outtextxy x - 10 80 quotEXITquot setcolor RED outtextxy x - 10 50 quotABOUT PRODUCERquot break case 3: setcolor WHITE outtextxy x - 10 20 quotSTARTquot outtextxy x - 10 50 quotABOUT PRODUCERquot setcolor RED outtextxy x - 10 80 quotEXITquot break int choose_operation int key t 1 operation 1 while 1 while bioskey1 0 key bioskey0 switch key case UP: if t 1 operation t else operation --t break case DOWN: if t 3 operation t else operation t break case LEFT: break case RIGHT: break default : return t void init_graph int gdriver EGA gmode EGAHI errorcode/ registerbgidriverEGAVGA_driver / initgraphampgdriver ampgmode quotquot errorcode graphresult if errorcode grOk printfquotGraphics error: squot grapherrormsgerrorcode printfquotPress any key to halt:quot getch exit1 void player_name setcolor RED settextstyle 3 0 1 outtextxy x - 260 10 quotCOMPUTER 1 :quot outtextxy x 256 10 quotCOMPUTER 2 :quot outtextxy x - 180 y 55 quotPLAYER :quotvoid init_card int i j for i 0 i lt 3 i for j 13 i j lt 13 i 13 j cardj.kind i cardj.num j - i 13 if cardj.num 7 cardj.card quot10quot else cardj.card amp card_value2 j - i 13 cardj.next NULL card52.kind 5 card53.kind 4 card52.num 13 card53.num 14 card52.card quotJOKERquot card53.card quotJOKERquot card53.next NULL card52.next NULLstruct card_node back_up struct card_node head / 用来备份用的/ struct card_node p head1 q head1 struct card_node malloc sizeof struct card_node head1 -gt kind head -gt kind head1 -gt num head -gt num head1 -gt card head -gt card head1 -gt next NULL for p head -gt next q head1 p NULL p p -gt next q -gt next struct card_node malloc sizeof struct card_node q q -gt next q -gt kind p -gt kind q -gt num p -gt num q -gt card p -gt card q -gt next NULL return head1void card_drawn int x int y int kind int num int color 宽 /传递坐标和牌的花色以及大小60,高80/ char str6 setfillstyle SOLID_FILL color bar x - 30 y - 40 x 30 y 40 setcolor BLUE rectangle x - 29 y - 39 x 29 y 39 switch kind case 0: setcolor RED sprintf str quotcquot 3 break case 1: setcolor RED sprintf str quotcquot 4 break case 2: setcolor BLACK sprintf str quotcquot 3 break case 3: setcolor BLACK sprintf str quotcquot 5 break case 5: setcolor LIGHTGRAY sprintf str quotsquot quotJOKERquot break case 4: setcolor RED sprintf str quotsquot quotJOKERquot break if kind lt 3 settextstyle 0 0 2 outtextxy x - 20 y - 29 str outtextxy x 21 y 30 str if num 7 settextstyle 0 0 1 outtextxy x - 21 y - 15 cardkind 13 num.card outtextxy x 21 y 16 cardkind 13 num.card settextstyle 4 0 4 outtextxy x y - 5 cardkind 13 num.card else settextstyle 1 0 1 outtextxy x - 21 y - 15 cardkind 13 num.card outtextxy x 21 y 10 cardkind 13 num.card settextstyle 4 0 5 outtextxy x - 1 y - 5 cardkind 13 num.card else settextstyle 0 1 1 outtextxy x - 21 y - 18 str outtextxy x 21 y 18 str settextstyle 4 0 5 outtextxy x y - 3 quotGquot void lord_choice int q setcolor BLUE settextstyle 3 0 1 outtextxy x y 50 quotDo You Want To Be the Lord quot if q 1 setcolor BLUE outtextxy x 40 y 65 quotNoquot setcolor LIGHTGRAY outtextxy x - 40 y 65 quotYesquot else setcolor LIGHTGRAY outtextxy x 40 y 65 quotNoquot setcolor BLUE outtextxy x - 40 y 65 quotYesquot int choose_lord int flag 1 key lord_choice 1 while 1 while bioskey 1 0 key bioskey 0 switch key case LEFT: lord_choice 1 flag 1 break case RIGHT: lord_choice 2 flag 2 break case UP: brea
上一篇:
【精品】中缀表达式转化为后缀表达式算法及后缀表达式计算算法
下一篇:
bc80e7a0-d1f2-4595-b21d-01a76798e87a