Membuat Lampu Lalu Lintas dengan Delphi

selamat malam sob (nulisnya pas malam :D ) kali ini saya posting tentang cara Membuat Lampu Lalu Lintas dengan Delphi . model lampu lalu lintas yang saya buat ini yaitu perempatan jadi sobat blogger buat dulu shape sebanyak 12, label saya pakai 5 label sob,   jangan lupa pasang timer yah sob :) kurang lebihnya penampakannya kayak di samping



 Nah klo udah jadi tunggu apa lgi sob., klik 2x pada timer lalu tuliskan listing di awah ini :

procedure TForm1.Timer1Timer(Sender: TObject);
var
a:integer;
begin
a:=StrToInt(label1.Caption);
a:=a-1;
label1.Caption:=IntToStr(a);
if label1.Caption='0' then label1.Caption:='25';

if a=20 then label2.Caption:='GO !!';
if a=20 then label3.Caption:='STOP !!';
if a=20 then label4.Caption:='GO !!';
if a=20 then label5.Caption:='STOP !!';

if a=20  then
 begin
Shape1.Brush.Color:=clWhite;
Shape2.Brush.Color:=clwhite;
Shape3.Brush.Color:=clgreen;
shape4.Brush.Color:=clRed;
shape5.Brush.color:=clwhite;
shape6.Brush.Color:=clwhite;
Shape7.Brush.Color:=clWhite;
Shape8.Brush.Color:=clwhite;
Shape9.Brush.Color:=clgreen;
shape10.Brush.Color:=clRed;
shape11.Brush.color:=clwhite;
shape12.Brush.Color:=clwhite;

  end

else if a=15 then
 begin
 Shape1.Brush.Color:=clWhite;
 Shape2.Brush.Color:=clyellow;
 Shape3.Brush.Color:=clwhite;
 shape4.Brush.Color:=clRed;
 shape5.Brush.color:=clwhite;
 shape6.Brush.Color:=clwhite;
 Shape7.Brush.Color:=clWhite;
 Shape8.Brush.Color:=clyellow;
 Shape9.Brush.Color:=clwhite;
 shape10.Brush.Color:=clRed;
 shape11.Brush.color:=clwhite;
 shape12.Brush.Color:=clwhite;
 end

else if a=10 then label2.Caption:='STOP !!';
  if a=10 then label3.Caption:='GO !!';
  if a=10 then label4.Caption:='STOP !!';
  if a=10 then label5.Caption:='GO !!';

 if a=10 then
begin
Shape1.Brush.Color:=clRed;
Shape2.Brush.Color:=clWhite;
Shape3.Brush.Color:=clWhite;
shape4.Brush.Color:=clwhite;
shape5.Brush.color:=clwhite;
shape6.Brush.Color:=clgreen;
Shape7.Brush.Color:=clRed;
Shape8.Brush.Color:=clWhite;
Shape9.Brush.Color:=clWhite;
shape10.Brush.Color:=clwhite;
shape11.Brush.color:=clwhite;
shape12.Brush.Color:=clgreen;
 end

else if a=5 then
 begin
Shape1.Brush.Color:=clred;
Shape2.Brush.Color:=clwhite;
Shape3.Brush.Color:=clWhite;
shape4.Brush.Color:=clwhite;
shape5.Brush.color:=clyellow;
shape6.Brush.Color:=clwhite;
Shape7.Brush.Color:=clred;
Shape8.Brush.Color:=clwhite;
Shape9.Brush.Color:=clWhite;
shape10.Brush.Color:=clwhite;
shape11.Brush.color:=clyellow;
shape12.Brush.Color:=clwhite;

end;
end;
end.
maka hasilnya akan seperti ini sobat blogger :














SELAMAT MENCOBA SOBAT BLOGGER !! ^_^ 
semoga bermanfaat sob :)

0 komentar:

Posting Komentar

Powered By Blogger