跳台游戏
本帖最后由 xieyuan0553 于 2015-10-6 07:16 编辑窗体初始化
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Timer1: TTimer;
Shape2: TShape;
Timer2: TTimer;
Shape3: TShape;
Timer3: TTimer;
Shape4: TShape;
Timer4: TTimer;
Shape5: TShape;
Timer5: TTimer;
Shape6: TShape;
Shape7: TShape;
Timer6: TTimer;
Timer7: TTimer;
Shape8: TShape;
Timer8: TTimer;
Shape9: TShape;
Image1: TImage;
Timer10: TTimer;
Timer11: TTimer;
Timer12: TTimer;
Timer13: TTimer;
Timer14: TTimer;
Timer15: TTimer;
Timer16: TTimer;
Timer17: TTimer;
Timer18: TTimer;
Label1: TLabel;
Timer9: TTimer;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure Timer4Timer(Sender: TObject);
procedure Timer5Timer(Sender: TObject);
procedure Timer6Timer(Sender: TObject);
procedure Timer7Timer(Sender: TObject);
procedure Timer8Timer(Sender: TObject);
procedure Timer9Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Timer10Timer(Sender: TObject);
procedure Timer11Timer(Sender: TObject);
procedure Timer12Timer(Sender: TObject);
procedure Timer13Timer(Sender: TObject);
procedure Timer14Timer(Sender: TObject);
procedure Timer15Timer(Sender: TObject);
procedure Timer16Timer(Sender: TObject);
procedure Timer17Timer(Sender: TObject);
procedure Timer18Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
第一个定时器(控制第一个(最下面的一个)矩形向右移动)
把Timer1的Interval属性改为1
把Timer1的Enabled改为True
procedure TForm1.Timer1Timer(Sender: TObject);
begin
shape1.Left:=shape1.Left+1;
if shape1.Left>=900 then
shape1.Left:=-100;
end;
第二个定时器(控制第二个矩形向左移动)
把Timer2的Interval属性改为3
把Timer1的Enabled改为True
procedure TForm1.Timer2Timer(Sender: TObject);
begin
shape2.Left:=shape2.Left-2;
if shape2.Left<=-95 then
shape2.Left:=900;
end;
第三个定时器(控制第三个矩形向右移动)
把Timer3的Interval属性改为1
把Timer3的Enabled改为True
procedure TForm1.Timer3Timer(Sender: TObject);
begin
shape3.Left:=shape3.Left+3;
if shape3.Left>=900 then
shape3.Left:=-90;
end;
第四个定时器(控制第四个矩形向左移动)
把Timer4的Interval属性改为2
把Timer4的Enabled改为True
procedure TForm1.Timer4Timer(Sender: TObject);
begin
shape4.Left:=shape4.Left-3;
if shape4.Left<=-85 then
shape4.Left:=900;
end;
第五个定时器(控制第五个矩形向右移动)
把Timer5的Interval属性改为4
把Timer5的Enabled改为True
procedure TForm1.Timer5Timer(Sender: TObject);
begin
shape5.Left:=shape5.Left+4;
if shape5.Left>=900 then
shape5.Left:=-80;
end;
第六个定时器(控制第六个矩形向左移动)
把Timer6的Interval属性改为5
把Timer6的Enabled改为True
procedure TForm1.Timer6Timer(Sender: TObject);
begin
shape6.Left:=shape6.Left-6;
if shape6.Left<=-75 then
shape6.Left:=900;
end;
第七个定时器(控制第七个矩形向右移动)
把Timer7的Interval属性改为3
把Timer7的Enabled改为True
procedure TForm1.Timer7Timer(Sender: TObject);
begin
shape7.Left:=shape7.Left+2;
if shape7.Left>=900 then
shape7.Left:=-70;
end;
第八个定时器(控制第八个矩形向左移动)
把Timer8的Interval属性改为2
把Timer8的Enabled改为True
procedure TForm1.Timer8Timer(Sender: TObject);
begin
shape8.Left:=shape8.Left-3;
if shape8.Left<=65 then
shape8.Left:=900;
end;
第九个定时器(控制第九个矩形向右移动)
把Timer9的Interval属性改为1
把Timer9的Enabled改为True
procedure TForm1.Timer9Timer(Sender: TObject);
begin
shape9.Left:=shape9.Left+3;
if shape9.Left>=900 then
shape9.Left:=-60;
end;
窗体(按键)
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=vk_up) and (Image1.Top=410) and (Image1.Left>=Shape1.Left) and (Image1.Left<=Shape1.Left+100) then
begin
Timer10.Enabled:=true;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=370) and (Image1.Left>=Shape2.Left) and (Image1.Left<=Shape2.Left+95) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=true;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=330) and (Image1.Left>=Shape3.Left) and (Image1.Left<=Shape3.Left+90) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=true;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=290) and (Image1.Left>=Shape4.Left) and (Image1.Left<=Shape4.Left+85) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=true;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=250) and (Image1.Left>=Shape5.Left) and (Image1.Left<=Shape5.Left+80) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=true;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=210) and (Image1.Left>=Shape6.Left) and (Image1.Left<=Shape6.Left+75) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=true;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=170) and (Image1.Left>=Shape7.Left) and (Image1.Left<=Shape7.Left+70) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=true;
Timer17.Enabled:=false;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=130) and (Image1.Left>=Shape8.Left) and (Image1.Left<=Shape8.Left+65) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=true;
Timer18.Enabled:=false;
end;
if (key=vk_up) and (Image1.Top=90) and (Image1.Left>=Shape9.Left) and (Image1.Left<=Shape9.Left+60) then
begin
Timer10.Enabled:=false;
Timer11.Enabled:=false;
Timer12.Enabled:=false;
Timer13.Enabled:=false;
Timer14.Enabled:=false;
Timer15.Enabled:=false;
Timer16.Enabled:=false;
Timer17.Enabled:=false;
Timer18.Enabled:=true;
end;
end;
第十个定时器(小人上第一块板子(最下面一块))
把Timer10的Interval属性改为1
把Timer10的Enabled改为False
procedure TForm1.Timer10Timer(Sender: TObject);
begin
Image1.Top:=370;
Image1.Left:=Image1.Left+1;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十一个定时器(小人上第二块板子)
把Timer11的Interval属性改为3
把Timer11的Enabled改为False
procedure TForm1.Timer11Timer(Sender: TObject);
begin
Image1.Top:=330;
Image1.Left:=Image1.Left-2;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十二个定时器(小人上第三块板子)
把Timer12的Interval属性改为1
把Timer12的Enabled改为False
procedure TForm1.Timer12Timer(Sender: TObject);
begin
Image1.Top:=290;
Image1.Left:=Image1.Left+3;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十三个定时器(小人上第四块板子)
把Timer13的Interval属性改为2
把Timer13的Enabled改为False
procedure TForm1.Timer13Timer(Sender: TObject);
begin
Image1.Top:=250;
Image1.Left:=Image1.Left-3;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十四个定时器(小人上第五块板子)
把Timer14的Interval属性改为4
把Timer14的Enabled改为False
procedure TForm1.Timer14Timer(Sender: TObject);
begin
Image1.Top:=210;
Image1.Left:=Image1.Left+4;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十五个定时器(小人上第六块板子)
把Timer15的Interval属性改为5
把Timer15的Enabled改为False
procedure TForm1.Timer15Timer(Sender: TObject);
begin
Image1.Top:=170;
Image1.Left:=Image1.Left-6;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十六个定时器(小人上第七块板子)
把Timer16的Interval属性改为3
把Timer16的Enabled改为False
procedure TForm1.Timer16Timer(Sender: TObject);
begin
Image1.Top:=130;
Image1.Left:= Image1.Left+2;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十七个定时器(小人上第八块板子)
把Timer17的Interval属性改为2
把Timer17的Enabled改为False
procedure TForm1.Timer17Timer(Sender: TObject);
begin
Image1.Top:=90;
Image1.Left:=Image1.Left-3;
if (Image1.Left<0) or (Image1.Left>900) then
begin
Label1.Visible:=true;
Label1.Caption:='你输了!';
end;
end;
第十八个定时器(小人上第九块板子)
把Timer18的Interval属性改为1
把Timer18的Enabled改为False
procedure TForm1.Timer18Timer(Sender: TObject);
begin
Image1.Top:=50;
Image1.Left:=Image1.Left+3;
if Image1.Top=50 then;
begin
Label1.Visible:=true;
Label1.Caption:='你赢了!';
end;
end;
end. 不错啊 666
页:
[1]