在好例子网,分享、交流、成长!
您当前所在位置:首页Pascal 开发实例Pascal编程基础 → NotesGussing

NotesGussing

Pascal编程基础

下载此实例 编辑此实例
  • 开发语言:Pascal
  • 实例大小:0.10M
  • 下载次数:0
  • 浏览次数:0
  • 发布时间:2026-05-19
  • 实例类别:Pascal编程基础
  • 发 布 人:qijian927
  • 文件格式:.rar
  • 所需积分:2
 相关标签: Si ES ss

实例介绍

【实例简介】用Delphi 11开发的多设备游戏,可在Window和安卓手机上运行

【实例截图】

from clipboard

from clipboard

【核心代码】

unit NotesMain;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,System.Rtti, System.Actions, FMX.ActnList,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl,
  FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts, FMX.ListBox, FMX.Objects,
  FMX.Edit;

type
  TMainForm = class(TForm)
    TabControl1: TTabControl;
    TabItemWelcome: TTabItem;
    TabItemPlay: TTabItem;
    Label1: TLabel;
    Label2: TLabel;
    ButtonStart: TButton;
    Label3: TLabel;
    ListBox1: TListBox;
    ButtonRestart: TButton;
    StyleBook1: TStyleBook;
    Image1: TImage;
    Image2: TImage;
    procedure ButtonStartClick(Sender: TObject);
    procedure ButtonRestartClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure AddItem();
    procedure DoSButtonOKClick(Sender: TObject);
    procedure DoComboBox1OnChange(Sender: TObject);
    procedure DoComboBox2OnChange(Sender: TObject);
    procedure DoComboBox3OnChange(Sender: TObject);
    procedure DoComboBox4OnChange(Sender: TObject);
    procedure GenarateNotes();
    procedure ResetCT();
    procedure AjustR2();
    procedure SetCQ();
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;
  n1,n2,n3,n4,c1,c2,c3,c4,r1,r2,ct1,ct2,ct3,ct4,cq1,cq2,cq3,cq4,cqa1,cqa2,cqa3,cqa4,cb1,cb2,cb3,cb4,step:integer;
implementation
uses
{$IFDEF ANDROID}
  Androidapi.Helpers,
  Androidapi.JNI.JavaTypes,
  Androidapi.JNI.Os,
{$ENDIF}
  FMX.DialogService;

{$R *.fmx}

function FindItemParent(Obj: TFmxObject; ParentClass: TClass): TFmxObject;
begin
  Result := nil;
  if Assigned(Obj.Parent) then
    if Obj.Parent.ClassType = ParentClass then
      Result := Obj.Parent
    else
      Result := FindItemParent(Obj.Parent, ParentClass);
end;

procedure TMainForm.GenarateNotes();
begin
  n1:=random(6) 1;
  n2:=random(6) 1;
  n3:=random(6) 1;
  n4:=random(6) 1;
  step:=0;
end;

procedure TMainForm.ResetCT();
begin
  ct1:=0;
  ct2:=0;
  ct3:=0;
  ct4:=0;
end;

procedure TMainForm.SetCQ();
begin
  cq1:=1;
  cq2:=1;
  cq3:=1;
  cq4:=1;
  if c1=c2 then
    cq1:=cq1 1;
  if c1=c3 then
    cq1:=cq1 1;
  if c1=c4 then
    cq1:=cq1 1;

  if c2=c1 then
    cq2:=cq2 1;
  if c2=c3 then
    cq2:=cq2 1;
  if c2=c4 then
    cq2:=cq2 1;

  if c3=c1 then
    cq3:=cq3 1;
  if c3=c2 then
    cq3:=cq3 1;
  if c3=c4 then
    cq3:=cq3 1;

  if c4=c1 then
    cq4:=cq4 1;
  if c4=c2 then
    cq4:=cq4 1;
  if c4=c3 then
    cq4:=cq4 1;
  cqa1:=cq1;
  cqa2:=cq2;
  cqa3:=cq3;
  cqa4:=cq4;
end;

procedure TMainForm.AjustR2();
begin
  while ct1>cqa1 do
  begin
    ct1:=ct1-1;
    r2:=r2-1;
  end;
  while ct2>cqa2 do
  begin
    ct2:=ct2-1;
    r2:=r2-1;
  end;
  while ct3>cqa3 do
  begin
    ct3:=ct3-1;
    r2:=r2-1;
  end;
  while ct4>cqa4 do
  begin
    ct4:=ct4-1;
    r2:=r2-1;
  end;
end;

procedure TMainForm.DoComboBox1OnChange(Sender: TObject);
var
  Item : TListBoxItem;
begin
  Item := TListBoxItem(FindItemParent(Sender as TFmxObject,TListBoxItem));
  if Assigned(Item) then
  begin
    c1:=StrToInt(TComboBox(Sender).Selected.Text);
    cb1:=1;
  end;
end;

procedure TMainForm.DoComboBox2OnChange(Sender: TObject);
var
  Item : TListBoxItem;
begin
  Item := TListBoxItem(FindItemParent(Sender as TFmxObject,TListBoxItem));
  if Assigned(Item) then
  begin
    c2:=StrToInt(TComboBox(Sender).Selected.Text);
    cb2:=1;
  end;
end;

procedure TMainForm.DoComboBox3OnChange(Sender: TObject);
var
  Item : TListBoxItem;
begin
  Item := TListBoxItem(FindItemParent(Sender as TFmxObject,TListBoxItem));
  if Assigned(Item) then
  begin
    c3:=StrToInt(TComboBox(Sender).Selected.Text);
    cb3:=1;
  end;
end;

procedure TMainForm.DoComboBox4OnChange(Sender: TObject);
var
  Item : TListBoxItem;
begin
  Item := TListBoxItem(FindItemParent(Sender as TFmxObject,TListBoxItem));
  if Assigned(Item) then
  begin
    c4:=StrToInt(TComboBox(Sender).Selected.Text);
    cb4:=1;
  end;
end;

procedure TMainForm.DoSButtonOKClick(Sender: TObject);
var
  Item : TListBoxItem;
begin
  if (cb1=1) and (cb2=1) and (cb3=1) and (cb4=1) then
  begin
    Item := TListBoxItem(FindItemParent(Sender as TFmxObject,TListBoxItem));
    setcq;
    if Assigned(Item) then
    begin
      if c1=n1 then   //c1=n1
      begin
        r1:=r1 1;
        if c2=n2 then   //c1=n1 c2=n2
        begin
          r1:=r1 1;
          if c3=n3 then    //c1=n1 c2=n2 c3=n3
          begin
            r1:=r1 1;
            if c4=n4 then   //c1=n1 c2=n2 c3=n3 c4=n4
              r1:=r1 1;
          end;
          if c3<>n3 then     //c1=n1 c2=n2 c3<>n3
          begin
            if c4=n4 then        //c1=n1 c2=n2 c3<>n3 c4=n4
              r1:=r1 1;
            if c4<>n4 then       //c1=n1 c2=n2 c3<>n3 c4<>n4
            begin
              if c3=n4 then
                r2:=r2 1;
              if c4=n3 then
                r2:=r2 1;
            end;
          end;
        end;

        if C2<>n2 then     //c1=n1 c2<>n2
        begin
          if c3=n3 then        //c1=n1 c2<>n2 c3=n3
          begin
            r1:=r1 1;
            if c4=n4 then     //c1=n1 c2<>n2 c3=n3 c4=n4
            begin
              r1:=r1 1;
            end;
            if c4<>n4 then   //c1=n1 c2<>n2 c3=n3 c4<>n4
            begin
              if c2=n4 then
                r2:=r2 1;
              if c4=n2 then
                r2:=r2 1;
            end;
          end;
          if c3<>n3 then     //c1=n1 c2<>n2 c3<>n3
          begin
            if c4=n4 then      //c1=n1 c2<>n2 c3<>n3 c4=n4
            begin
              r1:=r1 1;
              if (c2=n3) then
                r2:=r2 1;
              if c3=n2 then
                r2:=r2 1;
            end;
            if c4<>n4 then      //c1=n1 c2<>n2 c3<>n3 c4<>n4
            begin
              resetct;

              if (c3=n2) or (c4=n2) then
              begin
                r2:=r2 1;
                if c3=n2 then
                  ct3:=ct3 1;
                if c4=n2 then
                  ct4:=ct4 1;
              end;

              if (c2=n3) or (c4=n3) then
              begin
                r2:=r2 1;
                if c2=n3 then
                  ct2:=ct2 1;
                if c4=n3 then
                  ct4:=ct4 1;
              end;

              if (c2=n4) or (c3=n4) then
              begin
                r2:=r2 1;
                if c2=n4 then
                  ct2:=ct2 1;
                if c3=n4 then
                  ct3:=ct3 1;
              end;

              if (c2=n1) and (cq2>1) then
                cqa2:=1;
              if (c3=n1) and (cq3>1) then
                cqa3:=1;
              if (c4=n1) and (cq4>1) then
                cqa4:=1;
              AjustR2;
            end;
          end;
        end;
      end;

      if c1<>n1 then          //c1<>n1
      begin
        if c2=n2 then         //c1<>n1 c2=n2
        begin
          r1:=r1 1;
          if c3=n3 then       //c1<>n1 c2=n2 c3=n3
          begin
            r1:=r1 1;
            if c4=n4 then      //c1<>n1 c2=n2 c3=n3 c4=n4
            begin
              r1:=r1 1;
            end;
            if c4<>n4 then     //c1<>n1 c2=n2 c3=n3 c4<>n4
              if c1=n4 then
                r2:=r2 1;
              if (c4=n1) then
                r2:=r2 1;
          end;
          if c3<>n3 then       //c1<>n1 c2=n2 c3<>n3
          begin
            if c4=n4 then       //c1<>n1 c2=n2 c3<>n3 c4=n4
            begin
              r1:=r1 1;
              if (c1=n3) then
                r2:=r2 1;
              if c3=n1 then
                r2:=r2 1;
            end;
            if c4<>n4 then        //c1<>n1 c2=n2 c3<>n3 c4<>n4
            begin
              ResetCT;

              if (c3=n1) or (c4=n1) then
              begin
                r2:=r2 1;
                if c3=n1 then
                  ct3:=ct3 1;
                if c4=n1 then
                  ct4:=ct4 1;
              end;

              if (c1=n3) or (c4=n3) then
              begin
                r2:=r2 1;
                if c1=n3 then
                  ct1:=ct1 1;
                if c4=n3 then
                  ct4:=ct4 1;
              end;

              if (c1=n4) or (c3=n4) then
              begin
                r2:=r2 1;
                if c1=n4 then
                  ct1:=ct1 1;
                if c3=n4 then
                  ct3:=ct3 1;
              end;

              if (c1=n2) and (cq1>1) then
                cqa1:=1;
              if (c3=n2) and (cq3>1) then
                cqa3:=1;
              if (c4=n2) and (cq4>1) then
                cqa4:=1;
              AjustR2;
            end;
          end;
        end;
        if c2<>n2 then            //c1<>n1 c2<>n2
        begin
          if c3=n3 then           //c1<>n1 c2<>n2 c3=n3
          begin
            r1:=r1 1;
            if c4=n4 then         //c1<>n1 c2<>n2 c3=n3 c4=n4
            begin
              r1:=r1 1;
              if c1=n2 then
                r2:=r2 1;
              if c2=n1 then
                r2:=r2 1;
            end;
            if c4<>n4 then        //c1<>n1 c2<>n2 c3=n3 c4<>n4
            begin
              resetCT;

              if (c2=n1) or (c4=n1) then
              begin
                r2:=r2 1;
                if c2=n1 then
                  ct2:=ct2 1;
                if c4=n1 then
                  ct4:=ct4 1;
              end;

              if (c1=n2) or (c4=n2) then
              begin
                r2:=r2 1;
                if c1=n2 then
                  ct1:=ct1 1;
                if c4=n2 then
                  ct4:=ct4 1;
              end;

              if (c1=n4) or (c2=n4) then
              begin
                r2:=r2 1;
                if c1=n4 then
                  ct1:=ct1 1;
                if c2=n4 then
                  ct2:=ct2 1;
              end;

              if (c1=n3) and (cq1>1) then
                cqa1:=1;
              if (c2=n3) and (cq2>1) then
                cqa3:=1;
              if (c4=n3) and (cq4>1) then
                cqa4:=1;
              AjustR2;
            end;
          end;
          if c3<>n3 then          //c1<>n1 c2<>n2 c3<>n3
          begin
            if c4=n4 then          //c1<>n1 c2<>n2 c3<>n3 c4=n4
            begin
              resetCT;
              r1:=r1 1;

              if (c2=n1) or (c3=n1) then
              begin
                r2:=r2 1;
                if c2=n1 then
                  ct2:=ct2 1;
                if c3=n1 then
                  ct3:=ct3 1;
              end;

              if (c1=n2) or (c3=n2) then
              begin
                r2:=r2 1;
                if c1=n2 then
                  ct1:=ct1 1;
                if c3=n2 then
                  ct3:=ct3 1;
              end;

              if (c1=n3) or (c2=n3) then
              begin
                r2:=r2 1;
                if c1=n3 then
                  ct1:=ct1 1;
                if c2=n3 then
                  ct2:=ct2 1;
              end;

              if (c1=n4) and (cq1>1) then
                cqa1:=1;
              if (c2=n4) and (cq2>1) then
                cqa3:=1;
              if (c3=n4) and (cq3>1) then
                cqa3:=1;
              AjustR2;
            end;

            if c4<>n4 then         //c1<>n1 c2<>n2 c3<>n3 c4<>n4
            begin
              resetCT;
              if (c2=n1) or (c3=n1) or (c4=n1) then
              begin
                r2:=r2 1;
                if c2=n1 then
                  ct2:=ct2 1;
                if c3=n1 then
                  ct3:=ct3 1;
                if c4=n1 then
                  ct4:=ct4 1;
              end;

              if (c1=n2) or (c3=n2) or (c4=n2) then
              begin
                r2:=r2 1;
                if c1=n2 then
                  ct1:=ct1 1;
                if c3=n2 then
                  ct3:=ct3 1;
                if c4=n2 then
                  ct4:=ct4 1;
              end;

              if (c1=n3) or (c2=n3) or (c4=n3) then
              begin
                r2:=r2 1;
                if c1=n3 then
                  ct1:=ct1 1;
                if c2=n3 then
                  ct2:=ct2 1;
                if c4=n3 then
                  ct4:=ct4 1;
              end;

              if (c1=n4) or (c2=n4) or (c3=n4) then
              begin
                r2:=r2 1;
                if c1=n4 then
                  ct1:=ct1 1;
                if c2=n4 then
                  ct2:=ct2 1;
                if c3=n4 then
                  ct3:=ct3 1;
              end;
              AjustR2;
            end;
          end;
        end;
      end;

      if r1=4 then
      begin
        Item.StylesData['ImageItem1']:=Image1.Bitmap;
        Item.StylesData['ImageItem2']:=Image1.Bitmap;
        Item.StylesData['ImageItem3']:=Image1.Bitmap;
        Item.StylesData['ImageItem4']:=Image1.Bitmap;
        Item.Enabled:=false;
      end
      else
      begin
        if r1=3 then
        begin
          Item.StylesData['ImageItem1']:=Image1.Bitmap;
          Item.StylesData['ImageItem2']:=Image1.Bitmap;
          Item.StylesData['ImageItem3']:=Image1.Bitmap;
        end;

        if r1=2 then
        begin
          Item.StylesData['ImageItem1']:=Image1.Bitmap;
          Item.StylesData['ImageItem2']:=Image1.Bitmap;
          if r2=2 then
          begin
            Item.StylesData['ImageItem3']:=Image2.Bitmap;
            Item.StylesData['ImageItem4']:=Image2.Bitmap;
          end;
          if r2=1 then
            Item.StylesData['ImageItem3']:=Image2.Bitmap;
        end;

        if r1=1 then
        begin
          Item.StylesData['ImageItem1']:=Image1.Bitmap;
          if r2=3 then
          begin
            Item.StylesData['ImageItem2']:=Image2.Bitmap;
            Item.StylesData['ImageItem3']:=Image2.Bitmap;
            Item.StylesData['ImageItem4']:=Image2.Bitmap;
          end;
          if r2=2 then
          begin
            Item.StylesData['ImageItem2']:=Image2.Bitmap;
            Item.StylesData['ImageItem3']:=Image2.Bitmap;
          end;
          if r2=1 then
          begin
            Item.StylesData['ImageItem2']:=Image2.Bitmap;
          end;
        end;

        if r1=0 then
        begin
          if r2=1 then
            Item.StylesData['ImageItem1']:=Image2.Bitmap;
          if r2=2 then
          begin
            Item.StylesData['ImageItem1']:=Image2.Bitmap;
            Item.StylesData['ImageItem2']:=Image2.Bitmap;
          end;
          if r2=3 then
          begin
            Item.StylesData['ImageItem1']:=Image2.Bitmap;
            Item.StylesData['ImageItem2']:=Image2.Bitmap;
            Item.StylesData['ImageItem3']:=Image2.Bitmap;
          end;
          if r2=4 then
          begin
            Item.StylesData['ImageItem1']:=Image2.Bitmap;
            Item.StylesData['ImageItem2']:=Image2.Bitmap;
            Item.StylesData['ImageItem3']:=Image2.Bitmap;
            Item.StylesData['ImageItem4']:=Image2.Bitmap;
          end;
        end;
        Item.Enabled:=false;
        if step>9 then
          TDialogService.ShowMessage('尝试次数过多,还是重新开始吧。')
        else
          AddItem;
      end;
    end;
  end;
end;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ListBox1.Free;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  TabItemPlay.Visible:=false;
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
  TabControl1.ActiveTab:= TabItemWelcome;
end;

procedure TMainForm.AddItem();
var
  Item : TListBoxItem;
begin
  r1:=0;
  r2:=0;
  Item:=TListBoxItem.Create(nil);
  Item.Parent:=ListBox1;
  Item.StyleLookup:='CustomItem';
  Item.StylesData['ImageItem1']:=nil;
  Item.StylesData['ImageItem2']:=nil;
  Item.StylesData['ImageItem3']:=nil;
  Item.StylesData['ImageItem4']:=nil;
  Item.StylesData['ComboBox1.OnChange'] := TValue.From<TNotifyEvent>(DoComboBox1OnChange);
  Item.StylesData['ComboBox2.OnChange'] := TValue.From<TNotifyEvent>(DoComboBox2OnChange);
  Item.StylesData['ComboBox3.OnChange'] := TValue.From<TNotifyEvent>(DoComboBox3OnChange);
  Item.StylesData['ComboBox4.OnChange'] := TValue.From<TNotifyEvent>(DoComboBox4OnChange);
  Item.StylesData['SButtonOK.OnClick'] := TValue.From<TNotifyEvent>(DoSButtonOKClick);
  cb1:=0;
  cb2:=0;
  cb3:=0;
  cb4:=0;
  Step:=Step 1;
end;

procedure TMainForm.ButtonRestartClick(Sender: TObject);
begin
  ListBox1.Clear;
  GenarateNotes;
  AddItem;
end;

procedure TMainForm.ButtonStartClick(Sender: TObject);
begin
  ListBox1.Clear;
  GenarateNotes;
  AddItem;
  TabItemPlay.Visible:=true;
  TabControl1.ActiveTab:=TabItemPlay;
  TabItemWelcome.Visible:=false;
end;
end.

标签: Si ES ss

实例下载地址

NotesGussing

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警