鱼C论坛

 找回密码
 立即注册
查看: 1715|回复: 1

[原创] 走出雷区

[复制链接]
发表于 2015-11-2 09:41:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 xieyuan0553 于 2015-11-2 09:48 编辑


Form1窗体
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Shape1: TShape;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Image7: TImage;
    Image8: TImage;
    Image9: TImage;
    Image10: TImage;
    Image11: TImage;
    Image12: TImage;
    Image13: TImage;
    Image14: TImage;
    Image15: TImage;
    Image16: TImage;
    Image17: TImage;
    MainMenu1: TMainMenu;
    Start: TMenuItem;
    Label3: TLabel;
    Timer1: TTimer;
    Label4: TLabel;
    Image18: TImage;
    Image19: TImage;
    Help: TMenuItem;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Timer2: TTimer;
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
    procedure StartClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Label4MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Label4MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure HelpClick(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    if key=vk_left then
        if shape1.Left>0 then
            if image19.Visible=False then
            begin
                shape1.Left:=shape1.Left-20;
                image19.Left:=image19.Left-20;
            end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
         Timer2.Enabled:=False;
         Label5.Caption:='你输了';
         image19.Visible:=True;
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
    if key=vk_right then
        if shape1.Left<340 then
            if image19.Visible=False then
        begin
            image19.Left:=image19.Left+20;
            shape1.Left:=shape1.Left+20;

        end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
         Timer2.Enabled:=False;
         Label5.Caption:='你输了';
        image19.Visible:=True;
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
    if key=vk_up then
        if shape1.Top>0 then
            if image19.Visible=False then
            begin
                shape1.Top:=shape1.Top-20;
                image19.Top:=image19.Top-20;
            end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
        Timer2.Enabled:=False;
        image19.Visible:=True;
        Label5.Caption:='你输了';
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
    if key=vk_down then
        if shape1.Top<340 then
            if image19.Visible=False then
            begin
                shape1.Top:=shape1.Top+20;
                image19.Top:=image19.Top+20;
            end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
         Timer2.Enabled:=False;
         image19.Visible:=True;
         Label5.Caption:='你输了';
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    Panel1.Visible:=False;
    Label1.Visible:=False;
    Label2.Visible:=False;
end;

procedure TForm1.StartClick(Sender: TObject);
begin
    Timer2.Enabled:=True;
    Label3.Caption:='10';
    Label7.Caption:='0';
    image1.Visible:=False;
    image2.Visible:=False;
    image3.Visible:=False;
    image4.Visible:=False;
    image5.Visible:=False;
    image6.Visible:=False;
    image7.Visible:=False;
    image8.Visible:=False;
    image9.Visible:=False;
    image10.Visible:=False;
    image11.Visible:=False;
    image12.Visible:=False;
    image13.Visible:=False;
    image14.Visible:=False;
    image15.Visible:=False;
    image16.Visible:=False;
    image17.Visible:=False;
    image18.Visible:=False;
    image19.Visible:=false;
    image19.Left:=-24;
    image19.Top:=-16;
    Panel1.Visible:=True;
    Label1.Visible:=True;
    Label2.Visible:=True;
    Label5.Caption:='';
    shape1.Left:=0;
    shape1.Top:=0;
    Randomize;
    image1.Left:=20+20*trunc(Random(17));
    image2.Top:=20+20*trunc(Random(17));
    image3.Top:=20+20*trunc(Random(17));
    image4.Left:=20*trunc(Random(17));
    image5.Left:=20*trunc(Random(18));
    image6.Top:=20+20*trunc(Random(17));
    image7.Top:=20*trunc(Random(18));
    image8.Top:=100+20*trunc(Random(12));
    image9.Left:=120+20*trunc(Random(11));
    image10.Left:=80+20*trunc(Random(13));
    image11.Top:=20*trunc(Random(17));
    image12.Top:=20*trunc(Random(14));
    image13.Left:=40+20*trunc(Random(14));
    image14.Top:=20+20*trunc(Random(16));
    image15.Top:=60+20*trunc(Random(15));
    image16.Left:=120+20*trunc(Random(11));
    image17.Left:=20*trunc(Random(17));
    image18.Top:=20+trunc(Random(16));
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
    Label3.Caption:=IntToStr(StrToInt(Label3.Caption)-1);
    if Label3.Caption='0' then
    begin
        Timer1.Enabled:=False;
        image1.Visible:=False;
        image2.Visible:=False;
        image3.Visible:=False;
        image4.Visible:=False;
        image5.Visible:=False;
        image6.Visible:=False;
        image7.Visible:=False;
        image8.Visible:=False;
        image9.Visible:=False;
        image10.Visible:=False;
        image11.Visible:=False;
        image12.Visible:=False;
        image13.Visible:=False;
        image14.Visible:=False;
        image15.Visible:=False;
        image16.Visible:=False;
        image17.Visible:=False;
        image18.Visible:=False;
    end;
end;

procedure TForm1.Label4MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    Timer1.Enabled:=True;
    Image1.Visible:=True;
    Image2.Visible:=True;
    Image3.Visible:=True;
    Image4.Visible:=True;
    Image5.Visible:=True;
    Image6.Visible:=True;
    Image7.Visible:=True;
    Image8.Visible:=True;
    Image9.Visible:=True;
    Image10.Visible:=True;
    Image11.Visible:=True;
    Image12.Visible:=True;
    Image13.Visible:=True;
    Image14.Visible:=True;
    Image15.Visible:=True;
    Image16.Visible:=True;
    Image17.Visible:=True;
    Image18.Visible:=True;
    if Label3.Caption='0' then
    begin
        Timer1.Enabled:=False;
        image1.Visible:=False;
        image2.Visible:=False;
        image3.Visible:=False;
        image4.Visible:=False;
        image5.Visible:=False;
        image6.Visible:=False;
        image7.Visible:=False;
        image8.Visible:=False;
        image9.Visible:=False;
        image10.Visible:=False;
        image11.Visible:=False;
        image12.Visible:=False;
        image13.Visible:=False;
        image14.Visible:=False;
        image15.Visible:=False;
        image16.Visible:=False;
        image17.Visible:=False;
        image18.Visible:=False;
    end;
end;

procedure TForm1.Label4MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    Timer1.Enabled:=False;
    image1.Visible:=False;
    image2.Visible:=False;
    image3.Visible:=False;
    image4.Visible:=False;
    image5.Visible:=False;
    image6.Visible:=False;
    image7.Visible:=False;
    image8.Visible:=False;
    image9.Visible:=False;
    image10.Visible:=False;
    image11.Visible:=False;
    image12.Visible:=False;
    image13.Visible:=False;
    image14.Visible:=False;
    image15.Visible:=False;
    image16.Visible:=False;
    image17.Visible:=False;
    image18.Visible:=False;
   
end;

procedure TForm1.HelpClick(Sender: TObject);
begin
    Form2.ShowModal;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
    Label7.Caption:=IntToStr(StrToInt(Label7.Caption)+1);
end;

end.

object Form1: TForm1
  Left = 100
  Top = 197
  Width = 566
  Height = 473
  BorderIcons = [biSystemMenu]
  Caption = #36208#20986#38647#21306
  Color = clBlue
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = False
  OnCreate = FormCreate
  OnKeyDown = FormKeyDown
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 24
    Top = 32
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #20837#21475
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -27
    Font.Name = #21326#25991#24425#20113
    Font.Style = []
    ParentFont = False
  end
  object Label2: TLabel
    Left = 448
    Top = 368
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #20986#21475
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -27
    Font.Name = #21326#25991#24425#20113
    Font.Style = []
    ParentFont = False
  end
  object Label3: TLabel
    Left = 488
    Top = 112
    Width = 12
    Height = 13
    Caption = '10'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clAqua
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object Label4: TLabel
    Left = 472
    Top = 72
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #25552#31034
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -21
    Font.Name = #21326#25991#32454#40657
    Font.Style = []
    ParentFont = False
    OnMouseDown = Label4MouseDown
    OnMouseUp = Label4MouseUp
  end
  object Label6: TLabel
    Left = 472
    Top = 144
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #26102#38388
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -21
    Font.Name = #21326#25991#32454#40657
    Font.Style = []
    ParentFont = False
  end
  object Label7: TLabel
    Left = 472
    Top = 184
    Width = 33
    Height = 17
    Alignment = taRightJustify
    AutoSize = False
    Caption = '0'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clAqua
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object Panel1: TPanel
    Left = 80
    Top = 32
    Width = 360
    Height = 360
    Color = clBackground
    TabOrder = 0
    object Shape1: TShape
      Left = 0
      Top = 0
      Width = 20
      Height = 20
    end
    object Image1: TImage
      Left = 340
      Top = 0
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image2: TImage
      Left = 0
      Top = 100
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image3: TImage
      Left = 60
      Top = 200
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image4: TImage
      Left = 56
      Top = 340
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image5: TImage
      Left = 80
      Top = 60
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image6: TImage
      Left = 100
      Top = 140
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image7: TImage
      Left = 120
      Top = 140
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image8: TImage
      Left = 140
      Top = 140
      Width = 20
      Height = 20
      Picture.Data = {}
      Transparent = True
    end
    object Image9: TImage
      Left = 160
      Top = 180
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image10: TImage
      Left = 180
      Top = 260
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image11: TImage
      Left = 200
      Top = 280
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image12: TImage
      Left = 220
      Top = 280
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image13: TImage
      Left = 240
      Top = 20
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image14: TImage
      Left = 260
      Top = 220
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image15: TImage
      Left = 280
      Top = 220
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image16: TImage
      Left = 300
      Top = 260
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image17: TImage
      Left = 320
      Top = 320
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image18: TImage
      Left = 340
      Top = 20
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image19: TImage
      Left = -24
      Top = -16
      Width = 73
      Height = 65
      Picture.Data = {}
      Stretch = True
      Transparent = True
      Visible = False
    end
    object Label5: TLabel
      Left = 128
      Top = 128
      Width = 145
      Height = 49
      AutoSize = False
      Color = clNone
      Font.Charset = GB2312_CHARSET
      Font.Color = clRed
      Font.Height = -35
      Font.Name = #21326#25991#24425#20113
      Font.Style = [fsBold]
      ParentColor = False
      ParentFont = False
      Transparent = True
    end
  end
  object MainMenu1: TMainMenu
    Left = 408
    Top = 16
    object Start: TMenuItem
      Caption = #24320#22987#28216#25103'(&S)'
      OnClick = StartClick
    end
    object Help: TMenuItem
      Caption = #24110#21161'(&H)'
      OnClick = HelpClick
    end
  end
  object Timer1: TTimer
    Enabled = False
    OnTimer = Timer1Timer
    Left = 440
    Top = 24
  end
  object Timer2: TTimer
    Enabled = False
    OnTimer = Timer2Timer
    Left = 464
    Top = 24
  end
end

Form2窗体
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

end.

object Form2: TForm2
  Left = 245
  Top = 184
  Width = 176
  Height = 173
  BorderIcons = [biSystemMenu]
  Caption = #24110#21161
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 40
    Top = 24
    Width = 89
    Height = 17
    AutoSize = False
    Caption = #8593#65306#21521#19978#31227#21160
  end
  object Label2: TLabel
    Left = 40
    Top = 48
    Width = 89
    Height = 17
    AutoSize = False
    Caption = #8595#65306#21521#19979#31227#21160
  end
  object Label3: TLabel
    Left = 40
    Top = 72
    Width = 97
    Height = 25
    AutoSize = False
    Caption = #8592#65306#21521#24038#31227#21160
  end
  object Label4: TLabel
    Left = 40
    Top = 96
    Width = 97
    Height = 13
    AutoSize = False
    Caption = #8594#65306#21521#21491#31227#21160
  end
end
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2015-11-3 14:42:47 | 显示全部楼层
Form1窗体
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Shape1: TShape;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Image7: TImage;
    Image8: TImage;
    Image9: TImage;
    Image10: TImage;
    Image11: TImage;
    Image12: TImage;
    Image13: TImage;
    Image14: TImage;
    Image15: TImage;
    Image16: TImage;
    Image17: TImage;
    MainMenu1: TMainMenu;
    Start: TMenuItem;
    Label3: TLabel;
    Timer1: TTimer;
    Label4: TLabel;
    Image18: TImage;
    Image19: TImage;
    Help: TMenuItem;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Timer2: TTimer;
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
    procedure StartClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Label4MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Label4MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure HelpClick(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    if key=vk_left then
        if shape1.Left>0 then
            if image19.Visible=False then
            begin
                shape1.Left:=shape1.Left-20;
                image19.Left:=image19.Left-20;
            end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
         Timer2.Enabled:=False;
         Label5.Caption:='你输了';
         image19.Visible:=True;
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
    if key=vk_right then
        if shape1.Left<340 then
            if image19.Visible=False then
        begin
            image19.Left:=image19.Left+20;
            shape1.Left:=shape1.Left+20;

        end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
         Timer2.Enabled:=False;
         Label5.Caption:='你输了';
        image19.Visible:=True;
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
    if key=vk_up then
        if shape1.Top>0 then
            if image19.Visible=False then
            begin
                shape1.Top:=shape1.Top-20;
                image19.Top:=image19.Top-20;
            end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
        Timer2.Enabled:=False;
        image19.Visible:=True;
        Label5.Caption:='你输了';
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
    if key=vk_down then
        if shape1.Top<340 then
            if image19.Visible=False then
            begin
                shape1.Top:=shape1.Top+20;
                image19.Top:=image19.Top+20;
            end;
    if ((shape1.Left=image1.Left)and(shape1.Top=image1.Top))
     or((shape1.Left=image2.Left)and(shape1.Top=image2.Top))
     or((shape1.Left=image3.Left)and(shape1.Top=image3.Top))
     or((shape1.Left=image4.Left)and(shape1.Top=image4.Top))
     or((shape1.Left=image5.Left)and(shape1.Top=image5.Top))
     or((shape1.Left=image6.Left)and(shape1.Top=image6.Top))
     or((shape1.Left=image7.Left)and(shape1.Top=image7.Top))
     or((shape1.Left=image8.Left)and(shape1.Top=image8.Top))
     or((shape1.Left=image9.Left)and(shape1.Top=image9.Top))
     or((shape1.Left=image10.Left)and(shape1.Top=image10.Top))
     or((shape1.Left=image11.Left)and(shape1.Top=image11.Top))
     or((shape1.Left=image12.Left)and(shape1.Top=image12.Top))
     or((shape1.Left=image13.Left)and(shape1.Top=image13.Top))
     or((shape1.Left=image14.Left)and(shape1.Top=image14.Top))
     or((shape1.Left=image15.Left)and(shape1.Top=image15.Top))
     or((shape1.Left=image16.Left)and(shape1.Top=image16.Top))
     or((shape1.Left=image17.Left)and(shape1.Top=image17.Top))
     or((shape1.Left=image18.Left)and(shape1.Top=image18.Top))then
     begin
         Timer2.Enabled:=False;
         image19.Visible:=True;
         Label5.Caption:='你输了';
     end;
     if (shape1.Left=340) and (shape1.Top=340) then
     begin
         Label5.Caption:='你赢了';
         Timer2.Enabled:=False;
     end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    Panel1.Visible:=False;
    Label1.Visible:=False;
    Label2.Visible:=False;
end;

procedure TForm1.StartClick(Sender: TObject);
begin
    Timer2.Enabled:=True;
    Label3.Caption:='10';
    Label7.Caption:='0';
    image1.Visible:=False;
    image2.Visible:=False;
    image3.Visible:=False;
    image4.Visible:=False;
    image5.Visible:=False;
    image6.Visible:=False;
    image7.Visible:=False;
    image8.Visible:=False;
    image9.Visible:=False;
    image10.Visible:=False;
    image11.Visible:=False;
    image12.Visible:=False;
    image13.Visible:=False;
    image14.Visible:=False;
    image15.Visible:=False;
    image16.Visible:=False;
    image17.Visible:=False;
    image18.Visible:=False;
    image19.Visible:=false;
    image19.Left:=-24;
    image19.Top:=-16;
    Panel1.Visible:=True;
    Label1.Visible:=True;
    Label2.Visible:=True;
    Label5.Caption:='';
    shape1.Left:=0;
    shape1.Top:=0;
    Randomize;
    image1.Left:=20+20*trunc(Random(17));
    image2.Top:=20+20*trunc(Random(17));
    image3.Top:=20+20*trunc(Random(17));
    image4.Left:=20*trunc(Random(17));
    image5.Left:=20*trunc(Random(18));
    image6.Top:=20+20*trunc(Random(17));
    image7.Top:=20*trunc(Random(18));
    image8.Top:=100+20*trunc(Random(12));
    image9.Left:=120+20*trunc(Random(11));
    image10.Left:=80+20*trunc(Random(13));
    image11.Top:=20*trunc(Random(17));
    image12.Top:=20*trunc(Random(14));
    image13.Left:=40+20*trunc(Random(14));
    image14.Top:=20+20*trunc(Random(16));
    image15.Top:=60+20*trunc(Random(15));
    image16.Left:=120+20*trunc(Random(11));
    image17.Left:=20*trunc(Random(17));
    image18.Top:=20+trunc(Random(16));
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
    Label3.Caption:=IntToStr(StrToInt(Label3.Caption)-1);
    if Label3.Caption='0' then
    begin
        Timer1.Enabled:=False;
        image1.Visible:=False;
        image2.Visible:=False;
        image3.Visible:=False;
        image4.Visible:=False;
        image5.Visible:=False;
        image6.Visible:=False;
        image7.Visible:=False;
        image8.Visible:=False;
        image9.Visible:=False;
        image10.Visible:=False;
        image11.Visible:=False;
        image12.Visible:=False;
        image13.Visible:=False;
        image14.Visible:=False;
        image15.Visible:=False;
        image16.Visible:=False;
        image17.Visible:=False;
        image18.Visible:=False;
    end;
end;

procedure TForm1.Label4MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    Timer1.Enabled:=True;
    Image1.Visible:=True;
    Image2.Visible:=True;
    Image3.Visible:=True;
    Image4.Visible:=True;
    Image5.Visible:=True;
    Image6.Visible:=True;
    Image7.Visible:=True;
    Image8.Visible:=True;
    Image9.Visible:=True;
    Image10.Visible:=True;
    Image11.Visible:=True;
    Image12.Visible:=True;
    Image13.Visible:=True;
    Image14.Visible:=True;
    Image15.Visible:=True;
    Image16.Visible:=True;
    Image17.Visible:=True;
    Image18.Visible:=True;
    if Label3.Caption='0' then
    begin
        Timer1.Enabled:=False;
        image1.Visible:=False;
        image2.Visible:=False;
        image3.Visible:=False;
        image4.Visible:=False;
        image5.Visible:=False;
        image6.Visible:=False;
        image7.Visible:=False;
        image8.Visible:=False;
        image9.Visible:=False;
        image10.Visible:=False;
        image11.Visible:=False;
        image12.Visible:=False;
        image13.Visible:=False;
        image14.Visible:=False;
        image15.Visible:=False;
        image16.Visible:=False;
        image17.Visible:=False;
        image18.Visible:=False;
    end;
end;

procedure TForm1.Label4MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    Timer1.Enabled:=False;
    image1.Visible:=False;
    image2.Visible:=False;
    image3.Visible:=False;
    image4.Visible:=False;
    image5.Visible:=False;
    image6.Visible:=False;
    image7.Visible:=False;
    image8.Visible:=False;
    image9.Visible:=False;
    image10.Visible:=False;
    image11.Visible:=False;
    image12.Visible:=False;
    image13.Visible:=False;
    image14.Visible:=False;
    image15.Visible:=False;
    image16.Visible:=False;
    image17.Visible:=False;
    image18.Visible:=False;
   
end;

procedure TForm1.HelpClick(Sender: TObject);
begin
    Form2.ShowModal;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
    Label7.Caption:=IntToStr(StrToInt(Label7.Caption)+1);
end;

end.

object Form1: TForm1
  Left = 100
  Top = 197
  Width = 566
  Height = 473
  BorderIcons = [biSystemMenu]
  Caption = #36208#20986#38647#21306
  Color = clBlue
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = False
  OnCreate = FormCreate
  OnKeyDown = FormKeyDown
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 24
    Top = 32
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #20837#21475
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -27
    Font.Name = #21326#25991#24425#20113
    Font.Style = []
    ParentFont = False
  end
  object Label2: TLabel
    Left = 448
    Top = 368
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #20986#21475
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -27
    Font.Name = #21326#25991#24425#20113
    Font.Style = []
    ParentFont = False
  end
  object Label3: TLabel
    Left = 488
    Top = 112
    Width = 12
    Height = 13
    Caption = '10'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clAqua
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object Label4: TLabel
    Left = 472
    Top = 72
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #25552#31034
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -21
    Font.Name = #21326#25991#32454#40657
    Font.Style = []
    ParentFont = False
    OnMouseDown = Label4MouseDown
    OnMouseUp = Label4MouseUp
  end
  object Label6: TLabel
    Left = 472
    Top = 144
    Width = 57
    Height = 33
    AutoSize = False
    Caption = #26102#38388
    Font.Charset = GB2312_CHARSET
    Font.Color = clAqua
    Font.Height = -21
    Font.Name = #21326#25991#32454#40657
    Font.Style = []
    ParentFont = False
  end
  object Label7: TLabel
    Left = 472
    Top = 184
    Width = 33
    Height = 17
    Alignment = taRightJustify
    AutoSize = False
    Caption = '0'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clAqua
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object Panel1: TPanel
    Left = 80
    Top = 32
    Width = 360
    Height = 360
    Color = clBackground
    TabOrder = 0
    object Shape1: TShape
      Left = 0
      Top = 0
      Width = 20
      Height = 20
    end
    object Image1: TImage
      Left = 340
      Top = 0
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image2: TImage
      Left = 0
      Top = 100
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image3: TImage
      Left = 60
      Top = 200
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image4: TImage
      Left = 56
      Top = 340
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image5: TImage
      Left = 80
      Top = 60
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image6: TImage
      Left = 100
      Top = 140
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image7: TImage
      Left = 120
      Top = 140
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image8: TImage
      Left = 140
      Top = 140
      Width = 20
      Height = 20
      Picture.Data = {}
      Transparent = True
    end
    object Image9: TImage
      Left = 160
      Top = 180
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image10: TImage
      Left = 180
      Top = 260
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image11: TImage
      Left = 200
      Top = 280
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image12: TImage
      Left = 220
      Top = 280
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image13: TImage
      Left = 240
      Top = 20
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image14: TImage
      Left = 260
      Top = 220
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image15: TImage
      Left = 280
      Top = 220
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image16: TImage
      Left = 300
      Top = 260
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image17: TImage
      Left = 320
      Top = 320
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image18: TImage
      Left = 340
      Top = 20
      Width = 20
      Height = 20
      Picture.Data = {}
      Stretch = True
      Transparent = True
    end
    object Image19: TImage
      Left = -24
      Top = -16
      Width = 73
      Height = 65
      Picture.Data = {}
      Stretch = True
      Transparent = True
      Visible = False
    end
    object Label5: TLabel
      Left = 128
      Top = 128
      Width = 145
      Height = 49
      AutoSize = False
      Color = clNone
      Font.Charset = GB2312_CHARSET
      Font.Color = clRed
      Font.Height = -35
      Font.Name = #21326#25991#24425#20113
      Font.Style = [fsBold]
      ParentColor = False
      ParentFont = False
      Transparent = True
    end
  end
  object MainMenu1: TMainMenu
    Left = 408
    Top = 16
    object Start: TMenuItem
      Caption = #24320#22987#28216#25103'(&S)'
      OnClick = StartClick
    end
    object Help: TMenuItem
      Caption = #24110#21161'(&H)'
      OnClick = HelpClick
    end
  end
  object Timer1: TTimer
    Enabled = False
    OnTimer = Timer1Timer
    Left = 440
    Top = 24
  end
  object Timer2: TTimer
    Enabled = False
    OnTimer = Timer2Timer
    Left = 464
    Top = 24
  end
end

Form2窗体
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

end.

object Form2: TForm2
  Left = 245
  Top = 184
  Width = 176
  Height = 173
  BorderIcons = [biSystemMenu]
  Caption = #24110#21161
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 40
    Top = 24
    Width = 89
    Height = 17
    AutoSize = False
    Caption = #8593#65306#21521#19978#31227#21160
  end
  object Label2: TLabel
    Left = 40
    Top = 48
    Width = 89
    Height = 17
    AutoSize = False
    Caption = #8595#65306#21521#19979#31227#21160
  end
  object Label3: TLabel
    Left = 40
    Top = 72
    Width = 97
    Height = 25
    AutoSize = False
    Caption = #8592#65306#21521#24038#31227#21160
  end
  object Label4: TLabel
    Left = 40
    Top = 96
    Width = 97
    Height = 13
    AutoSize = False
    Caption = #8594#65306#21521#21491#31227#21160
  end
end
走出雷区1.bmp.jpg.png
走出雷区3.bmp.jpg.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-22 17:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表