Professional Documents
Culture Documents
Nugroho Adi P
Burung
Pipa
Burung
Vertikal
Gravitasi
Pipa
Horisontal
Burung
Pipa
Skor
Kalah
menabrak pipa
jatuh
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure awal;
procedure gambarburung;
procedure gambarpipa;
procedure proses;
procedure burungjatuh;
procedure gerakkanpipa;
procedure tabrakpipa;
procedure Timer1Timer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
const
g = -10.0;
dt = 0.1;
var
Form1: TForm1;
x0,y0:integer;
vy:real=0;
mulai:boolean=false;
yb:real;
burung:tshape;
pipa: array [1..10] of tshape;
implementation
{$R *.dfm}
procedure tform1.awal;
begin{}
randomize;
x0:=round(form1.Width/2);
y0:=round(form1.Height/2);
yb:=y0;
form1.Canvas.TextOut(0,0,'Tekan sembarang tombol untuk memulai');
gambarpipa;
gambarburung;
end;
procedure tform1.gambarburung;
begin
burung:=tshape.Create(form1);
burung.Left:=x0;
burung.Top:=y0;
burung.Width:=20;
burung.Height:=20;
burung.Parent:=form1;
end;
procedure tform1.gambarpipa;
begin{}
pipa[1]:=tshape.Create(form1);
pipa[1].Height:=300;
pipa[1].Left:=form1.Width;
pipa[1].Top:=form1.Height-pipa[1].Height;
pipa[1].Parent:=form1;
end;
procedure tform1.gerakkanpipa;
begin
pipa[1].Left:=pipa[1].Left-11;
if pipa[1].Left<=0 then begin
pipa[1].Height:=random(200)+100;
pipa[1].Left:=form1.Width;
pipa[1].Top:=form1.Height-pipa[1].Height;
end;
end;
procedure tform1.tabrakpipa;
begin
if burung.Left>=pipa[1].Left then begin
if burung.Left<=pipa[1].Left+pipa[1].Height then begin
if burung.Top>=pipa[1].Top then begin
mulai:=false;
form1.Canvas.TextOut(0,0,'nabrak');
end;
end;
end;
end;
procedure tform1.burungjatuh;
begin
if burung.Top>=form1.Height then begin
mulai:=false;
form1.Canvas.TextOut(0,0,'hehehe');
end;
end;
procedure tform1.proses;
begin
while mulai=true do begin
vy:=vy+g*dt;
yb:=yb-vy*dt;
burung.Top:=round(yb);
burungjatuh;
gerakkanpipa;
tabrakpipa;
application.ProcessMessages; sleep(10);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=false;
awal;
end;