Thema: Delphi ampel programmieren

Einzelnen Beitrag anzeigen

Homer S.

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

Re: ampel programmieren

  Alt 19. Mär 2009, 09:17
Hallo zusammen,
Es handelt sich um Delphi 5!!!
ich habe hier eine Ampelkreuzung mit 2 Ampeln dies klappt soweit.
Ich bitte um eure hilfe, wie ich das auf 4 Ampeln mit Autos erweitere.
Außerdem sollten die Ampeln wie in echt schalten .
Bitte beachtet das ich ein anfänger bin .
Poste einfach mal den Quelltext:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, 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;
    procedure shpRed2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Timer1Timer(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 := 3000;
   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 := 3000;
   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 := 3000;
   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 := 3000;
      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;
    end.
  Mit Zitat antworten Zitat