Einzelnen Beitrag anzeigen

Homer S.

Registriert seit: 18. Mär 2009
5 Beiträge
 
#1

Brauche Hilfe bei Delphi 5 Ampelsystem

  Alt 20. Mär 2009, 08:12
Hallo zusammen,
Es handelt sich um Delphi 5!!!
ich habe hier eine Ampelkreuzung mit 4 Ampeln dies klappt soweit.
Ich bitte um eure hilfe, dass ihr mir sagt wie ich autos hinbekomme und die rote und grüne ampelzeit länger hält.
Bitte beachtet das ich anfänger bin!!
Unten mein Quelltext:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    shpRed1: TShape;
    shpYellow1: TShape;
    shpGreen1: TShape;
    shpYellow2: TShape;
    shpRed2: TShape;
    shpGreen2: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    Shape29: TShape;
    Shape30: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape31: TShape;
    Shape40: TShape;
    Shape41: TShape;
    Shape42: TShape;
    Shape43: TShape;
    Shape44: TShape;
    Shape45: TShape;
    Shape46: TShape;
    Shape47: TShape;
    Shape48: TShape;
    Shape49: TShape;
    Shape50: TShape;
    Shape51: TShape;
    Shape52: TShape;
    Shape53: TShape;
    Shape54: TShape;
    Shape55: TShape;
    Shape56: TShape;
    Shape57: TShape;
    Shape59: TShape;
    Shape60: TShape;
    Shape61: TShape;
    Shape62: TShape;
    Shape63: TShape;
    Shape64: TShape;
    Shape65: TShape;
    Shape66: TShape;
    Shape67: TShape;
    Shape68: TShape;
    Button1: TButton;
    Timer1: TTimer;
    shpRed4: TShape;
    shpYellow4: TShape;
    shpGreen4: TShape;
    shpRed3: TShape;
    shpYellow3: TShape;
    shpGreen3: TShape;
    Timer2: TTimer;
    Button2: TButton;
    procedure shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Close;
end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin
   if shpGreen2.Brush.Color = clblack then
   begin
   Timer1.interval := 2000;
   shpRed2.Brush.Color := clred;
   shpYellow2.Brush.Color := clblack;
   shpGreen2.Brush.Color := clnone;
   shpRed1.Brush.Color := clred;
   shpYellow1.Brush.Color := clblack;
   shpGreen1.Brush.Color := clnone;
    end
   else if shpYellow2.Brush.Color = clblack then
   begin
   Timer1.interval := 2000;
   shpRed2.Brush.Color := clred;
   shpYellow2.Brush.Color := clyellow;
   shpGreen2.Brush.Color := clnone;
   shpRed1.Brush.Color := clred;
   shpYellow1.Brush.Color := clyellow;
   shpGreen1.Brush.Color := clnone;
    end
   else if shpRed2.Brush.Color = clred then
   begin
   Timer1.interval := 2000;
   shpRed2.Brush.Color := clnone;
   shpYellow2.Brush.Color := clnone;
   shpGreen2.Brush.Color := cllime;
   shpRed1.Brush.Color := clnone;
   shpYellow1.Brush.Color := clnone;
   shpGreen1.Brush.Color := cllime;
   end
   else if shpGreen2.Brush.Color = cllime then
      begin
      Timer1.interval := 2000;
      shpRed2.Brush.Color := clblack;
      shpYellow2.Brush.Color := clyellow;
      shpGreen2.Brush.Color := clblack;
      shpRed1.Brush.Color := clblack;
      shpYellow1.Brush.Color := clyellow;
      shpGreen1.Brush.Color := clblack;
      end
    end;
    procedure TForm1.Timer2Timer(Sender: TObject);

   begin
   if shpGreen4.Brush.Color = clblack then
   begin
   Timer2.interval := 2000;
   shpRed4.Brush.Color := clred;
   shpYellow4.Brush.Color := clblack;
   shpGreen4.Brush.Color := clnone;
   shpRed3.Brush.Color := clred;
   shpYellow3.Brush.Color := clblack;
   shpGreen3.Brush.Color := clnone;
    end
   else if shpYellow4.Brush.Color = clblack then
   begin
   Timer2.interval := 2000;
   shpRed4.Brush.Color := clred;
   shpYellow4.Brush.Color := clyellow;
   shpGreen4.Brush.Color := clnone;
   shpRed3.Brush.Color := clred;
   shpYellow3.Brush.Color := clyellow;
   shpGreen3.Brush.Color := clnone;
    end
   else if shpRed4.Brush.Color = clred then
   begin
   Timer2.interval := 2000;
   shpRed4.Brush.Color := clnone;
   shpYellow4.Brush.Color := clnone;
   shpGreen4.Brush.Color := cllime;
   shpRed3.Brush.Color := clnone;
   shpYellow3.Brush.Color := clnone;
   shpGreen3.Brush.Color := cllime;
   end
   else if shpGreen4.Brush.Color = cllime then
      begin
      Timer2.interval := 2000;
      shpRed4.Brush.Color := clblack;
      shpYellow4.Brush.Color := clyellow;
      shpGreen4.Brush.Color := clblack;
      shpRed3.Brush.Color := clblack;
      shpYellow3.Brush.Color := clyellow;
      shpGreen3.Brush.Color := clblack;
      end
    end;


procedure TForm1.Button2Click(Sender: TObject);
begin

end;

end.
  Mit Zitat antworten Zitat