You are on page 1of 12

Flappy Bird

Nugroho Adi P

Tuesday, March 25, 14

Burung
Pipa

Tuesday, March 25, 14

Burung

Vertikal
Gravitasi

Tuesday, March 25, 14

Pipa

Horisontal

Tuesday, March 25, 14

Burung

naik jika layar disentuh ->


tekan sebarang tombol

Tuesday, March 25, 14

Pipa

posisi lubang acak

Tuesday, March 25, 14

Skor

berhasil melewati pipa

Tuesday, March 25, 14

Kalah

menabrak pipa
jatuh

Tuesday, March 25, 14

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}

Tuesday, March 25, 14

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;

Tuesday, March 25, 14

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;

Tuesday, March 25, 14

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;


Shift: TShiftState);
begin
mulai:=true;
vy:=30;
proses;
end;
end.

Tuesday, March 25, 14

You might also like