berikut ini adalah scriptnya...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, ExtCtrls, StdCtrls, jpeg;
type
TForm1
= class(TForm)
Panel1: TPanel;
pohon: TImage;
Jeruk: TImage;
kotak: TImage;
jerukTimer: TTimer;
waktuTimer: TTimer;
btnMain: TButton;
Label1: TLabel;
Label2: TLabel;
lbl60: TLabel;
lbl0: TLabel;
Label5: TLabel;
kucing: TImage;
kucingTimer: TTimer;
bintang: TImage;
bintangTimer:
TTimer;
tengkorak: TImage;
tengkorakTimer: TTimer;
shutdown: TImage;
shutdownTimer: TTimer;
btnpetunjuk: TButton;
btnkeluar: TButton;
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y:
Integer);
procedure jerukTimerTimer(Sender: TObject);
procedure waktuTimerTimer(Sender: TObject);
procedure btnMainClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure pohonMouseMove(Sender: TObject; Shift: TShiftState; X,
Y:
Integer);
procedure kucingTimerTimer(Sender: TObject);
procedure bintangTimerTimer(Sender: TObject);
procedure tengkorakTimerTimer(Sender: TObject);
procedure shutdownTimerTimer(Sender: TObject);
procedure btnpetunjukClick(Sender: TObject);
procedure btnkeluarClick(Sender: TObject);
private
{
Private declarations }
public
{
Public declarations }
end;
var
Form1:
TForm1;
Overlay: TRect;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Panel1MouseMove(Sender:
TObject; Shift: TShiftState; X,
Y:
Integer);
begin
kotak.left:=x-kotak.width div 2;
panel1.Cursor:=crNone;
end;
procedure TForm1.jerukTimerTimer(Sender:
TObject);
begin
Jeruk.Top:=Jeruk.Top+10;
if Jeruk.Top>panel1.Height then
begin
Jeruk.Top:=0;
Jeruk.Left:=random(panel1.Width);
end;
if
intersectRect(overlay,Jeruk.BoundsRect,kotak.BoundsRect) then
begin
Jeruk.Visible:=True;
Jeruk.Top:=0;
Jeruk.Left:=random(panel1.Width);
lbl0.Tag:=lbl0.Tag+1;
lbl0.caption:=inttostr(lbl0.Tag);
end;
end;
procedure TForm1.waktuTimerTimer(Sender:
TObject);
begin
lbl60.Tag:=lbl60.Tag-1;
lbl60.Caption:=inttostr(lbl60.tag);
if lbl60.Tag =0 then
begin
btnMain.Enabled:=true;
waktuTimer.Enabled:=false;
panel1.Enabled:=false;
jerukTimer.Enabled:=false;
kucingTimer.Enabled:=false;
bintangTimer.Enabled:=false;
tengkorakTimer.Enabled:=false;
kotak.Enabled:=false;
Jeruk.Enabled:=false;
Kucing.Enabled:=false;
Bintang.Enabled:=false;
tengkorak.Enabled:=false;
panel1.Caption:='Klik Main lagi jika ingin
main lagi';
end;
end;
procedure TForm1.btnMainClick(Sender:
TObject);
begin
btnMain.Caption:='MAIN LAGI';
btnMain.Enabled:=false;
panel1.Enabled:=true;
jerukTimer.Enabled:=true;
waktuTimer.Enabled:=true;
kucingTimer.Enabled:=true;
BintangTimer.Enabled:=true;
tengkorakTimer.Enabled:=true;
shutdownTimer.Enabled:=true;
kotak.Visible:=true;
Jeruk.Visible:=true;
kucing.Visible:=true;
Bintang.Visible:=true;
tengkorak.Visible:=true;
shutdown.Visible:=true;
panel1.Caption:='';
Jeruk.Top:=0;
kucing.Top:=0;
Bintang.Top:=0;
tengkorak.Top:=0;
shutdown.Top:=0;
lbl60.Caption:='60';
lbl60.Tag:=60;
lbl0.Caption:='0';
lbl0.Tag:=0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
kotak.Top:=392;
Jeruk.Top:=0;
kucing.Top:=0;
Bintang.Top:=0;
tengkorak.Top:=0;
shutdown.Top:=0
end;
procedure TForm1.pohonMouseMove(Sender:
TObject; Shift: TShiftState; X,
Y:
Integer);
begin
kotak.Left:=X-kotak.Width div 2;
panel1.Cursor:=crNone;
end;
procedure TForm1.kucingTimerTimer(Sender:
TObject);
begin
Kucing.Top:=Kucing.Top+10;
if Kucing.Top>panel1.Height then
begin
Kucing.Top:=0;
Kucing.Left:=random(panel1.Width);
end;
if
intersectRect(overlay,Kucing.BoundsRect,kotak.BoundsRect) then
begin
Kucing.Visible:=True;
Kucing.Top:=0;
Kucing.Left:=random(panel1.Width);
lbl0.Tag:=lbl0.Tag-1;
lbl0.caption:=inttostr(lbl0.Tag);
end;
end;
procedure TForm1.bintangTimerTimer(Sender:
TObject);
begin
Bintang.Top:=Bintang.Top+10;
if Bintang.Top>panel1.Height then
begin
Bintang.Top:=0;
Bintang.Left:=random(panel1.Width);
end;
if
intersectRect(overlay,Bintang.BoundsRect,kotak.BoundsRect) then
begin
Bintang.Visible:=True;
Bintang.Top:=0;
Bintang.Left:=random(panel1.Width);
lbl60.Tag:=lbl60.Tag+1;
lbl60.caption:=inttostr(lbl60.Tag);
end;
end;
procedure TForm1.tengkorakTimerTimer(Sender:
TObject);
begin
tengkorak.Top:=tengkorak.Top+10;
if tengkorak.Top>panel1.Height then
begin
tengkorak.Top:=0;
tengkorak.Left:=random(panel1.Width);
end;
if
intersectRect(overlay,tengkorak.BoundsRect,kotak.BoundsRect) then
begin
tengkorak.Visible:=True;
tengkorak.Top:=0;
tengkorak.Left:=random(panel1.Width);
lbl60.Tag:=lbl60.Tag-1;
lbl60.caption:=inttostr(lbl60.Tag);
end;
end;
procedure TForm1.shutdownTimerTimer(Sender:
TObject);
begin
shutdown.Top:=tengkorak.Top+10;
if shutdown.Top>panel1.Height then
begin
shutdown.Top:=0;
shutdown.Left:=random(panel1.Width);
end;
if
intersectRect(overlay,shutdown.BoundsRect,kotak.BoundsRect) then
begin
shutdown.Visible:=True;
shutdown.Top:=0;
shutdown.Left:=random(panel1.Width);
showmessage('Maaf permainan anda berakhir');
close;
end;
end;
procedure TForm1.btnpetunjukClick(Sender:
TObject);
begin
form2.show;
form1.Hide;
end;
procedure TForm1.btnkeluarClick(Sender:
TObject);
begin
close;
end;
0 komentar:
Posting Komentar