Wednesday, February 27, 2008

Animasi mudah di delphi (a simple animation for delphi)

procedure TFrmMain.TmrAnimasiTimer(Sender: TObject);begin if arahHor = 1 then ImgBola.Left:=ImgBola.Left + 25 else ImgBola.Left:=ImgBola.Left - 25; if arahVer = 1 then ImgBola.Top:=ImgBola.Top - 25 else ImgBola.Top:=ImgBola.Top + 25; if ImgBola.Left + ImgBola.Width = PnlArea.Width then arahHor:=0; if ImgBola.Left = 0 then arahHor:=1; if ImgBola.Top + ImgBola.Height = PnlArea.Height then arahVer:=1; if ImgBola.Top = 0 then arahVer:=0;end;
procedure TFrmMain.TrkWaktuChange(Sender: TObject);begin TmrAnimasi.Interval:=TrkWaktu.Position;end;
procedure TFrmMain.Button1Click(Sender: TObject);var bentuk : integer; Lokasi : string;begin Lokasi:=ExtractFilePath(Application.ExeName); randomize; bentuk := random(4)+1; if bentuk = 1 then ImgBola.Picture.LoadFromFile(Lokasi+'Merah.jpg') else if bentuk = 2 then ImgBola.Picture.LoadFromFile(Lokasi+'Hijau.jpg') else if bentuk = 3 then ImgBola.Picture.LoadFromFile(Lokasi+'Biru.jpg') else if bentuk = 4 then ImgBola.Picture.LoadFromFile(Lokasi+'Kuning.jpg')
end;
procedure TFrmMain.PnlAreaClick(Sender: TObject);begin
end;
end.