Cari Blog Ini

Selasa, 30 November 2010

delphi Animasi 3 ball move


Created with Delphi 7 by Avid/Kira
Animasi 3 ball move


Sintak:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    procedure Timer1Timer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  atas, bawah, kiri, kanan, at, bu, kr, kn, a, b, k, r:integer;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
{shape1}
if (atas=1) then
shape1.top:=shape1.Top-1;
if (bawah=1) then
shape1.Top:=shape1.Top+1;
if (kanan=1) then
shape1.left:=shape1.Left+1;
if (kiri=1) then
shape1.Left:=shape1.Left-1;
if (shape1.left>390) then
begin
kiri:=1;
kanan:=0;
end;
if (shape1.left<=0) then
begin
kanan:=1;
kiri:=0;
end;
if (shape1.top<=0) then
begin
atas:=0;
bawah:=1;
end;
if (shape1.top>370) then
begin
atas:=1;
bawah:=0;
end;
{shape2}
if (at=1) then
shape2.Top:=shape2.Top-1;
if (bu=1) then
shape2.Top:=shape2.Top+1;
if (kn=1) then
shape2.Left:=shape2.Left+1;
if (kr=1) then
shape2.Left:=shape2.Left-1;
if (shape2.left>390) then
begin
kr:=1;
kn:=0;
end;
if (shape2.left<=0) then
begin
kn:=1;
kr:=0;
end;
if (shape2.top<=0) then
begin
at:=0;
bu:=1;
end;
if (shape2.top>370) then
begin
at:=1;
bu:=0;
end;
{shape3}
if (a=1) then
shape3.Top:=shape3.Top-1;
if (b=1) then
shape3.Top:=shape3.Top+1;
if (k=1) then
shape3.Left:=shape3.Left+1;
if (r=1) then
shape3.Left:=shape3.Left-1;
if (shape3.left>390) then
begin
r:=1;
k:=0;
end;
if (shape3.left<=0) then
begin
k:=1;
r:=0;
end;
if (shape3.top<=0) then
begin
a:=0;
b:=1;
end;
if (shape3.top>370) then
begin
a:=1;
b:=0;
end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
application.Terminate;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
timer1.Enabled:=true;
{shape1}
kanan:=1;bawah:=1;
{shape2}
kr:=1;at:=1;
{shape3}
k:=1;a:=1;
end;

end.

Tidak ada komentar:

Posting Komentar