• <label id="pxtpz"><meter id="pxtpz"></meter></label>
      1. <span id="pxtpz"><optgroup id="pxtpz"></optgroup></span>

        當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

        5子棋源代碼

        5子棋源代碼

        更新時間:2022-05-16 文章作者:未知 信息來源:網絡 閱讀次數:

        unit Main;  

        interface  

        uses  
         Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,  
         ExtCtrls, StdCtrls, ComCtrls, Buttons, Graphics, mmsystem;  

        type  
         TForm1 = class(TForm)  
          StatusBar1: TStatusBar;  
          GroupBox1: TGroupBox;  
          GroupBox2: TGroupBox;  
          Panel1: TPanel;  
          Label1: TLabel;  
          BitBtn1: TBitBtn;  
          BitBtn2: TBitBtn;  
          Label3: TLabel;  
          Label4: TLabel;  
          BitBtn3: TBitBtn;  
          Image1: TImage;  
          Image2: TImage;  
          Label5: TLabel;  
          Label2: TLabel;  
          Label6: TLabel;  
          Label7: TLabel;  
          Label8: TLabel;  
          Label9: TLabel;  
          Label10: TLabel;  
          Timer1: TTimer;  
          Label11: TLabel;  
          procedure BitBtn2Click(Sender: TObject);  
          procedure BitBtn1Click(Sender: TObject);  
          procedure Image2MouseDown(Sender: TObject; Button: TMouseButton;  
           Shift: TShiftState; X, Y: Integer);  
          procedure FormCreate(Sender: TObject);  
          procedure BitBtn3Click(Sender: TObject);  
          procedure Timer1Timer(Sender: TObject);  
          procedure Label11MouseDown(Sender: TObject; Button: TMouseButton;  
           Shift: TShiftState; X, Y: Integer);  

         private  
          { Private declarations }  
         public  
          { Public declarations }  
         end;  

         FiveChess_Struct=record  
             x1 : integer;  
             y1 : integer;  
             x2 : integer;  
             y2 : integer;  
             state : byte;  
         end;  
         FiveChess_Data=array [0..14,0..14] of FiveChess_Struct;  

         Player = ( NON,White,Black);  

        var  
         Form1: TForm1;  
         Start_Flag : Boolean;  
         FiveChess_Array:FiveChess_Data ;  
         Online: player;  
         whitewin,blackwin:byte;  
         whitetime,blacktime:integer;  
         px1,px2,py1,py2 : integer;  

         Undo_i,Undo_j : integer;  
        function Ini_Main():Boolean ;  
        implementation  

        uses Option;  

        {$R *.DFM}  
        //{$R AOE.RES}  


        procedure Ini_FiveChess_Array();  
        var  
          i , j,k: integer;  
        begin  

           For i:=0 to 14 do begin  
             For j:=0 to 14 do begin  
               FiveChess_Array[i,j].x1:=16+25*j;  
               FiveChess_Array[i,j].y1:=16+25*i;  
               FiveChess_Array[i,j].x2:=36+25*j;  
               FiveChess_Array[i,j].y2:=36+25*i;  
               FiveChess_Array[i,j].state:=0;  
               end;  
            end;  
        end;  

        procedure Draw_qipan();  
        var  
           i,j : integer;  
        begin  
           Form1.Image2.Canvas.Brush.Color:=RGB(247,207,16);  
           Form1.Image2.Canvas.FillRect(Rect(0,0,400,400));  
           Form1.Image2.Canvas.pen.Color:=RGB(0,0,0);  
           for i:=1 to 16 do begin  
             Form1.Image2.Canvas.MoveTo(0,25*i);  
             Form1.Image2.Canvas.LineTo (400,25*i);  
             Form1.Image2.Canvas.MoveTo(25*i,0);  
             Form1.Image2.Canvas.LineTo (25*i,400);  
           end;  

        end;  


        procedure Undo_Run();  
        var  
           x1,x2,y1,y2 : integer;  
        begin  




           if (Undo_i<>-1) and (Undo_j<>-1) then  begin  
             FiveChess_array[Undo_i,Undo_j].state :=0;  
             x1:= FiveChess_Array[Undo_i,Undo_j].x1-2;  
             y1:= FiveChess_Array[Undo_i,Undo_j].y1-2;  
             x2:= FiveChess_Array[Undo_i,Undo_j].x2+2;  
             y2:= FiveChess_Array[Undo_i,Undo_j].y2+2;  
             Form1.Image2.Canvas.Brush.Color:=RGB(247,207,16);  
             Form1.Image2.Canvas.FillRect(rect(x1,y1,x2,y2));  
             Form1.Image2.Canvas.pen.Color:=RGB(0,0,0);  
             Form1.Image2.Canvas.MoveTo((x1+x2)div 2-1 , y1);  
             Form1.Image2.Canvas.LineTo((x1+x2)div 2-1 , y2);  
             Form1.Image2.Canvas.MoveTo(x1,(y1+y2)div 2-1);  
             Form1.Image2.Canvas.LineTo(x2,(y1+y2)div 2-1);  

             end;  

           If Online=black then  
             Online:=White  
           else  
             Online:=Black;    


        end;  



        function Ini_Main():Boolean ;  


        begin  

           Result:=true;  

           px1:=0;  
           px2:=0;  
           py1:=0;  
           py2:=0;  

           Undo_i:=-1;  
           Undo_j:=-1;  

           whitetime:=0;  
           blacktime:=0;  

           form1.Label9.Caption :=inttostr(whitewin);  
           form1.Label10.Caption :=inttostr(blackwin);  


           Ini_FiveChess_Array;  
           Draw_Qipan;  
        end;  






        Function Judge_Success_on_off (X,Y,State:integer):Boolean;  
        var  
           i,j,k,count : integer;  
        begin  
           Count:=0;  
           Result:=false;  

           // 判斷豎列  
           For i:=X-4 to X+4 do  
             if (i>=0) and (i<=15) then
              begin
                 if FiveChess_array[i,y].state=state then
                   begin
                     Inc(Count) ;
                     if count=5 then begin
                       result:=true;
                       break;
                       end;
                   end
                 else
                   Count:=0;
              end;
           //判斷橫行
           count:=0;
           For j:=y-4 to y+4 do
             if (j>=0) and (j<=15) then
              begin
                 if FiveChess_array[X,j].state=state then
                   begin
                     Inc(Count) ;
                     if count=5 then begin
                       result:=true;
                       break;
                       end;
                   end
                 else
                   Count:=0;
              end;
           //判斷'\'方向
           count:=0;
           For k:=-4 to 4 do begin
               i:=X+k;
               j:=Y+k;
               if (j>=0) and (j<=15) And(i>=0) and(i<=15) then
                begin
                 if FiveChess_array[i,j].state=state then
                   begin
                     Inc(Count) ;
                     if count=5 then begin
                       result:=true;
                       break;
                       end;
                   end
                 else
                   Count:=0;
              end;
           end;
          //判斷'/'方向
           count:=0;
           For k:=-4 to 4 do begin
               i:=X+k;
               j:=Y-k;
               if (j>=0) and (j<=15) And(i>=0) and(i<=15) then
                begin
                 if FiveChess_array[i,j].state=state then
                   begin
                     Inc(Count) ;
                     if count=5 then begin
                       result:=true;
                       break;
                       end;
                   end
                 else
                   Count:=0;
              end;
           end;

        end;



        procedure TForm1.BitBtn2Click(Sender: TObject);
        begin
           Application.Terminate ;
        end;

        procedure TForm1.BitBtn1Click(Sender: TObject);
        begin
           Start_Flag:=true;
           If Start_Flag then begin
            Form1.Image2.Enabled := true;
            Form1.Timer1.Enabled := true;
            Ini_Main;

           end;

        end;

        function Draw_Qizi_White(X,Y : Integer):boolean;
        var
           i,j,x1,x2,y1,y2 : integer;
        begin
           result := false;
           for i:=0 to 14 do
             For j:=0 to 14 do begin
               if (X> FiveChess_Array[i,j].x1)and(X<FiveChess_Array[i,j].x2)
              and (y> FiveChess_Array[i,j].y1)and(y<FiveChess_Array[i,j].y2)
              and (FiveChess_Array[i,j].state=0)  then
              begin
                 if FiveChess_Array[Undo_i,Undo_j].state<>0 then begin  
                  Form1.Image2.Canvas.Brush.Color:=Rgb(100,100,100);  
                  Form1.Image2.Canvas.FillRect (Rect(px1,py1,px2,py2));  
                 end;  

                 Form1.Image2.Canvas.Brush.Color:=Rgb(255,255,255);  
                 Form1.Image2.Canvas.Ellipse ( FiveChess_Array[i,j].x1,  
                 FiveChess_Array[i,j].y1,FiveChess_Array[i,j].x2,FiveChess_Array[i,j].y2);  
                 Form1.Image2.Canvas.Brush.Color:=RGB(255,255,255);  
                 Form1.Image2.Canvas.Ellipse ( FiveChess_Array[i,j].x1-2,  
                 FiveChess_Array[i,j].y1-2,FiveChess_Array[i,j].x2-2,FiveChess_Array[i,j].y2-2);  
                 FiveChess_array[i,j].state:=1;  

                 Undo_i:=i;  
                 Undo_j:=j;  


                 Form1.Image2.Canvas.Brush.Color:=clred;  
                 px1:= FiveChess_Array[i,j].x1+3;  
                 py1:= FiveChess_Array[i,j].y1+3;  
                 px2:= FiveChess_Array[i,j].x2-7;  
                 py2:= FiveChess_Array[i,j].y2-7;  
                 Form1.Image2.Canvas.Ellipse (px1,py1,px2,py2);  





                 if Judge_Success_on_off(i,j, FiveChess_Array[i,j].state) then  
                  begin  
                     whitewin:=whitewin+1;  
                     if whitewin>1 then  
                      Application.MessageBox ('臭棋簍!比魚頭還臭!','勝敗乃兵家常事',0)  
                     else  
                      Application.MessageBox ('白方已勝利!','勝敗乃兵家常事',0);  

                     form1.label9.caption:=inttostr(whitewin);  
                     form1.Image2.Enabled :=false;  
                     Form1.Timer1.Enabled := false;  
                  end;  

                 Result := true;  
                 break;  
              end;  
           end;  
        end;  

        function Draw_Qizi_Black(X,Y : Integer): boolean;  
        var  
           i,j,x1,x2,y1,y2 : integer;  
        begin  
           result:=false;  
           for i:=0 to 14 do  
             for j:=0 to 14 do begin  
               if (X> FiveChess_Array[i,j].x1)and(X<FiveChess_Array[i,j].x2)
                 and (y> FiveChess_Array[i,j].y1)and(y<FiveChess_Array[i,j].y2)
                 and (FiveChess_Array[i,j].state=0)  then
                 begin
                   if FiveChess_Array[Undo_i,Undo_j].state<>0 then begin  
                     Form1.Image2.Canvas.Brush.Color:=Rgb(255,255,255);  
                     Form1.Image2.Canvas.FillRect (Rect(px1,py1,px2,py2));  
                   end;  
                   Form1.Image2.Canvas.Brush.Color:=RGB(0,0,0);  
                   Form1.Image2.Canvas.Ellipse ( FiveChess_Array[i,j].x1,  
                      FiveChess_Array[i,j].y1,FiveChess_Array[i,j].x2,FiveChess_Array[i,j].y2);  
                   Form1.Image2.Canvas.Brush.Color:=RGB(100,100,100);  
                   Form1.Image2.Canvas.Ellipse ( FiveChess_Array[i,j].x1-2,  
                   FiveChess_Array[i,j].y1-2,FiveChess_Array[i,j].x2-2,FiveChess_Array[i,j].y2-2);  

                   FiveChess_array[i,j].state := 2;  

                   Undo_i:=i;  
                   Undo_j:=j;  

                   Form1.Image2.Canvas.Brush.Color:=clred;  
                   px1:= FiveChess_Array[i,j].x1+3;  
                   py1:= FiveChess_Array[i,j].y1+3;  
                   px2:= FiveChess_Array[i,j].x2-7;  
                   py2:= FiveChess_Array[i,j].y2-7;  
                   Form1.Image2.Canvas.Ellipse (px1,py1,px2,py2);  


                   if Judge_Success_on_off(i,j, FiveChess_Array[i,j].state) then  
                    begin  
                       blackwin:=blackwin+1;  
                       if blackwin>1 then  
                        Application.MessageBox ('不會吧!難道比魚頭還臭!','勝敗乃兵家常事',0)  
                       else  
                        Application.MessageBox ('黑方已勝利!','勝敗乃兵家常事',0);  

                       form1.label10.caption:=inttostr(blackwin);  
                       form1.Image2.Enabled :=false;  
                       Form1.Timer1.enabled := False;  
                    end;  
                   Result:=true;  
                   break;  
                 end;  
           end;  
        end;  

        procedure TForm1.Image2MouseDown(Sender: TObject; Button: TMouseButton;  
         Shift: TShiftState; X, Y: Integer);  

        begin  
             if Online = White then  begin  
              if draw_Qizi_white(X,Y) then  
                Online := Black  
              end  
             else  
                if draw_Qizi_Black(X,Y) then  
                 Online:=White;  



        end;  

        procedure TForm1.FormCreate(Sender: TObject);  
        begin  
           Online:=white;  
           form1.Label11.Caption :='人不到傷痕累累'#13+'就不會懂得后悔!';  
           Start_Flag:=false;  
           Form1.Image2.Enabled := false;  
             



        end;  

        procedure TForm1.BitBtn3Click(Sender: TObject);  
        begin  
            form2.show;  

        end;  

        procedure TForm1.Timer1Timer(Sender: TObject);  
        begin  
           if online=white then  
             whitetime:=whitetime +1  
           else  
             blacktime:=blacktime +1;  

           Form1.Label7.caption:=inttostr(whitetime);  
           Form1.Label8.caption:=inttostr(blacktime);  



        end;  

        procedure TForm1.Label11MouseDown(Sender: TObject; Button: TMouseButton;  
         Shift: TShiftState; X, Y: Integer);  
        begin  
           if (Button = mbleft) and (ssShift in shift) And (form1.Image2.Enabled = true)then  
             Undo_Run;  

           end;  


        end.  

        end;  


        //////////////////////////  


        unit Option;  

        interface  

        uses  
         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  
         StdCtrls, Buttons;  

        type  
         TForm2 = class(TForm)  
          GroupBox1: TGroupBox;  
          RadioButton1: TRadioButton;  
          RadioButton2: TRadioButton;  
          BitBtn1: TBitBtn;  
          BitBtn2: TBitBtn;  
          GroupBox2: TGroupBox;  
          RadioButton3: TRadioButton;  
          RadioButton4: TRadioButton;  
          RadioButton5: TRadioButton;  
          procedure FormCreate(Sender: TObject);  
          procedure BitBtn1Click(Sender: TObject);  
          procedure BitBtn2Click(Sender: TObject);  
         private  
          { Private declarations }  
         public  
          { Public declarations }  
         end;  

        var  
         Form2: TForm2;  


        implementation  


        uses  
           Main;  
        {$R *.DFM}  

        procedure TForm2.FormCreate(Sender: TObject);  
        begin  
            form2.RadioButton1.Checked := true;  
            form2.RadioButton3.Checked := true;  
        end;  

        procedure TForm2.BitBtn1Click(Sender: TObject);  
        begin  
           if form2.RadioButton1.Checked = true then  
             Online := White  
           else  
             Online := Black;  

           if  form2.RadioButton3.Checked then  
              begin  
                 whitewin:=0;  
                 blackwin:=0;  
              end ;  


           Ini_main;  


           form2.close;  




        end;  

        procedure TForm2.BitBtn2Click(Sender: TObject);  
        begin  
           form2.Close ;  
        end;  

        end.

        溫馨提示:喜歡本站的話,請收藏一下本站!

        本類教程下載

        系統下載排行

        主站蜘蛛池模板: 在线观看亚洲一区二区| 亚洲精品无码久久久影院相关影片 | 女人18毛片a级毛片免费| 亚洲毛片免费观看| 91成年人免费视频| 久久精品亚洲AV久久久无码| 嫖丰满老熟妇AAAA片免费看| 亚洲国产成人超福利久久精品| 五月婷婷综合免费| 亚洲精品伦理熟女国产一区二区| 日韩一区二区三区免费体验| 国产偷国产偷亚洲高清在线| 亚洲第一区在线观看| 中文字幕无线码免费人妻| 国产亚洲av片在线观看播放| 蜜桃成人无码区免费视频网站 | 深夜福利在线视频免费| 在线a亚洲v天堂网2019无码| 暖暖免费在线中文日本| 亚洲啪啪免费视频| 国产成人无码免费视频97| 人成午夜免费大片在线观看| 亚洲高清国产AV拍精品青青草原| 最近2019年免费中文字幕高清| 亚洲AV综合色区无码二区偷拍| 国产一级淫片a免费播放口之| 国产va免费精品| 亚洲成人黄色网址| 国产亚洲精品免费| 久久精品视频免费看| 亚洲精品国产av成拍色拍| 最新国产AV无码专区亚洲| 亚洲电影在线免费观看| 亚洲AV无码AV日韩AV网站| 亚洲精品国产字幕久久不卡| 黄+色+性+人免费| 中文永久免费观看网站| 亚洲 日韩经典 中文字幕| 亚洲午夜精品一级在线播放放| 巨波霸乳在线永久免费视频 | 亚洲AV永久无码精品放毛片|