Anda di halaman 1dari 9

PADA PERTEMUAN KALI INI KITA BELAJAR TENTANG TIMER&GAME PADA DELPHI 7

Buat form seperti gambar dibawah


Lalu klik kiri 2x pada form dan masukkan syntax berikut

procedure TForm1.FormCreate(Sender: TObject);

begin

timer1.Enabled:=false;

label1.Caption:='Halo Praktikan';

button1.Caption:='Blink';

timer2.Enabled:=false;

timer3.Enabled:=false;

label2.Caption:='Selamat Datang';

button2.Caption:='Marque';

timer4.Enabled:=false;

label4.Caption:='Lab Teknik Informatika';

button3.Caption:='Typing';

end;

end.

Pada button timer 1

Masukkan syntax berikut

unit Unit1;

interface
uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

TForm1 = class(TForm)

Timer1: TTimer;

Timer2: TTimer;

Timer3: TTimer;

Timer4: TTimer;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Button1: TButton;

Button2: TButton;

Button3: TButton;

procedure FormCreate(Sender: TObject);

procedure Timer4Timer(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Timer2Timer(Sender: TObject);

procedure Timer3Timer(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);


private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

jumChar:Integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);

begin

timer1.Enabled:=false;

label1.Caption:='Halo Praktikan';

button1.Caption:='Blink';

timer2.Enabled:=false;

timer3.Enabled:=false;

label2.Caption:='Selamat Datang';

button2.Caption:='Marque';
timer4.Enabled:=false;

label4.Caption:='Lab Teknik Informatika';

button3.Caption:='Typing';

end;

procedure TForm1.Timer4Timer(Sender: TObject);

begin

jumChar:=Length(label4.Caption);

case jumChar of

1:label4.Caption:=Label4.Caption+'a';

2:label4.Caption:=Label4.Caption+'b';

3:label4.Caption:=Label4.Caption+' ';

4:label4.Caption:=Label4.Caption+'T';

5:label4.Caption:=Label4.Caption+'e';

6:label4.Caption:=Label4.Caption+'k';

7:label4.Caption:=Label4.Caption+'n';

8:label4.Caption:=Label4.Caption+'i';

9:label4.Caption:=Label4.Caption+'k';

10:label4.Caption:=Label4.Caption+' ';

11:label4.Caption:=Label4.Caption+'I';

12:label4.Caption:=Label4.Caption+'n';

13:label4.Caption:=Label4.Caption+'f';

14:label4.Caption:=Label4.Caption+'o';

15:label4.Caption:=Label4.Caption+'r';

16:label4.Caption:=Label4.Caption+'m';
17:label4.Caption:=Label4.Caption+'a';

18:label4.Caption:=Label4.Caption+'t';

19:label4.Caption:=Label4.Caption+'i';

20:label4.Caption:=Label4.Caption+'k';

21:label4.Caption:=Label4.Caption+'a';

22:label4.Caption:='L';

end

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

if label1.Visible then label1.Visible:=false

else label1.visible:=true;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

if button1.caption='Blink' then

begin

timer1.Enabled:=true;

button1.Caption:='Stop'

end

else if button1.Caption='Stop'then

FormCreate(sender);

end;
procedure TForm1.Timer2Timer(Sender: TObject);

begin

label2.Left:=label2.left+1;

if(label2.left>=200) then

begin

timer2.Enabled:=false;

timer3.Enabled:=true;

label2.Left:=label2.Left+1;

end

end;

procedure TForm1.Timer3Timer(Sender: TObject);

begin

label2.Left:=label2.left-1;

if(label2.left<=30) then

begin

timer2.Enabled:=true;

timer3.Enabled:=false;

label2.Left:=label2.Left-1;

end

end;

procedure TForm1.Button2Click(Sender: TObject);

begin
if button2.caption='Marque'then

begin

timer2.Enabled:=true;

timer3.enabled:=false;

button2.Caption:='Stop'

end

else if button2.caption='Stop' then

FormCreate(sender);

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

if button3.caption='Typing'then

begin

timer4.Enabled:=true;

button3.Caption:='Stop'

end

else if button3.caption='Stop' then

FormCreate(sender);

end;

end.

Output