unit Ampel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
licht: Byte;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
(* Lichtvariable rotiert von 1 bis 16 *)
IF licht < 17 THEN licht := licht + 1;
IF licht = 17 THEN licht := 1;
(* Licht den Zeitscheiben zuweisen *)
CASE licht OF
1..6:
begin
Shape1.Brush.Color := clRed;
Shape2.Brush.Color := clBlack;
Shape3.Brush.Color := clBlack;
Shape4.Brush.Color := clBlack;
Shape5.Brush.Color := clBlack;
Shape6.Brush.Color := clLime;
end;
7:
begin
Shape1.Brush.Color := clRed;
Shape2.Brush.Color := clBlack;
Shape3.Brush.Color := clBlack;
Shape4.Brush.Color := clBlack;
Shape5.Brush.Color := clYelow;
Shape6.Brush.Color := cBlack;
end;
8:
begin
Shape1.Brush.Color := clRed;
Shape2.Brush.Color := clYellow;
Shape3.Brush.Color := clBlack;
Shape4.Brush.Color := clBlack;
Shape5.Brush.Color := clYelow;
Shape6.Brush.Color := cBlack;
end;
9..14:
begin
Shape1.Brush.Color := clBlack;
Shape2.Brush.Color := clBlack;
Shape3.Brush.Color := clLime;
Shape4.Brush.Color := clRed;
Shape5.Brush.Color := clBlack;
Shape6.Brush.Color := clBlack;
end;
15:
begin
Shape1.Brush.Color := clBlack;
Shape2.Brush.Color := clYellow;
Shape3.Brush.Color := clBlack;
Shape4.Brush.Color := clRed;
Shape5.Brush.Color := clBlack;
Shape6.Brush.Color := clBlack;
end;
16:
begin
Shape1.Brush.Color := clBlack;
Shape2.Brush.Color := clYellow;
Shape3.Brush.Color := clBlack;
Shape4.Brush.Color := clRed;
Shape5.Brush.Color := clYellow;
Shape6.Brush.Color := clBlack;
end;
END; // of case
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
licht := 0;
end;
end.