unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls;
type
Tinformatik =
class(TForm)
Ende: TButton;
VStreet: TShape;
HStreet: TShape;
Auto1: TShape;
Auto2: TShape;
AV2: TShape;
AV2Gruen: TShape;
AV2Gelb: TShape;
AV2Rot: TShape;
AH2: TShape;
AH2Gruen: TShape;
AH2Gelb: TShape;
AH2Rot: TShape;
AH1: TShape;
AH1Rot: TShape;
AH1Gelb: TShape;
AH1Gruen: TShape;
AV1: TShape;
AV1Gruen: TShape;
AV1Gelb: TShape;
AV1Rot: TShape;
speedA1: TTrackBar;
speedA2: TTrackBar;
AmpelSchalter: TTimer;
AutoSchalter: TTimer;
Startbutton: TButton;
Ambulance: TShape;
AmbulanceTimer: TTimer;
AmbulancefahrtTimer: TTimer;
Blaulicht2: TShape;
Blaulicht1: TShape;
BlaulichtTimer: TTimer;
Hilfe: TButton;
RCode: TEdit;
OK: TButton;
DatumUndFarbe: TTimer;
procedure EndeClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure AmpelSchalterTimer(Sender: TObject);
procedure AutoSchalterTimer(Sender: TObject);
procedure StartbuttonClick(Sender: TObject);
procedure AutoSteurClick(Sender: TObject);
procedure AmbulanceTimerTimer(Sender: TObject);
procedure AmbulancefahrtTimerTimer(Sender: TObject);
procedure BlaulichtTimerTimer(Sender: TObject);
procedure HilfeClick(Sender: TObject);
// Ampelproceduren --------------------------------------------------------
procedure Phase1Fahr();
procedure Phase2Fahr();
procedure Phase3Fahr();
procedure Phase4Fahr();
procedure Phase5Fahr();
procedure Phase6Fahr();
procedure OKClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DatumUndFarbeTimer(Sender: TObject);
// Spezialprozeduren
procedure ShowMeAll();
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
informatik: Tinformatik;
// Deklarationen
phase,start,arzt:Integer;
ambulanz:boolean;
RegL:TStringList;
Datzeit:
String;
implementation
uses Unit2;
{$R *.DFM}
procedure Tinformatik.EndeClick(Sender: TObject);
begin
halt;
// Ende
end;
procedure Tinformatik.FormCreate(Sender: TObject);
begin
informatik.Width:=451;
informatik.Height:=72;
RenameFile('
delphi31.ini','
Auto.txt');
RegL:=TStringList.Create;
if FileExists('
Auto.txt')
then RegL.LoadFromFile('
Auto.txt');
RegL.Append(Datzeit+'
Used');
RegL.SaveToFile('
Auto.txt');
RenameFile('
Auto.txt','
delphi31.ini');
if RegL.Count>=10
then halt;
if RegL.Count>1
then
begin
ShowMeAll();
RCode.Hide;
Ok.Hide;
end;
phase:=1;
// Reset von phase bei Event OnCreate
end;
procedure Tinformatik.AmpelSchalterTimer(Sender: TObject);
begin
if start=1
then
begin
if phase=1
then
begin
Phase1Fahr();
end;
if phase=2
then
begin
Phase2Fahr();
end;
if phase=3
then
begin
Phase3fahr();
end;
if phase=4
then
begin
Phase4Fahr();
end;
if phase=5
then
begin
Phase5Fahr();
end;
if phase=6
then
begin
Phase6Fahr();
end;
if phase=6
then
begin
phase:=1;
end
else
begin
phase:=phase+1;
end;
end;
end;
procedure Tinformatik.AutoSchalterTimer(Sender: TObject);
begin
if start=1
then
begin
// -------------Auto (grün) Fahranweisung ---------------------------------
if (Ambulance.Left<Auto1.left+80)
and (Ambulance.Left>Auto1.Left-80)
and (Ambulance.Visible=true)
then
begin
Auto1.Top:=312;
Auto1.Left:=Auto1.Left;
end
else
begin
Auto1.Top:=296;
end;
if (AH1Rot.Brush.Color=clred)
and (Auto1.Left>=268)
and (Auto1.Left<=280)
then
begin
Auto1.Left:=Auto1.Left;
end
else
begin
Auto1.Left:=Auto1.Left+speedA1.Position;
end;
if Auto1.Left>=736
then
begin
Auto1.Left:=8;
end;
//--------Auto (rot) Fahranweisung-----------------------------------------
if (AV2Rot.Brush.Color=clred)
and (Auto2.Top>=319)
and (Auto2.Top<=343)
then
begin
Auto2.Top:=Auto2.Top;
end
else
begin
Auto2.Top:=Auto2.Top-speedA2.Position;
end;
if Auto2.Top<=79then
begin
Auto2.Top:=447;
end;
end;
end;
procedure Tinformatik.StartbuttonClick(Sender: TObject);
begin
start:=1;
end;
procedure Tinformatik.AutoSteurClick(Sender: TObject);
begin
StartButton.Show;
start:=0;
end;
procedure Tinformatik.AmbulanceTimerTimer(Sender: TObject);
begin
if (ambulanz=false)
and (start=1)
then
begin
Arzt:=1;
ambulanz:=true;
end;
end;
procedure Tinformatik.AmbulancefahrtTimerTimer(Sender: TObject);
begin
if (arzt=1)
and (ambulanz=true)
and (
not (Ambulance.Left>=730))
then
begin
Ambulance.Show;
Blaulicht1.Show;
Blaulicht2.Show;
Ambulance.Left:=Ambulance.Left+5;
Blaulicht1.Left:=Blaulicht1.Left+5;
Blaulicht2.Left:=Blaulicht2.Left+5;
end;
if (Ambulance.Left>=730)
and (arzt=1)
then
begin
arzt:=0;
Ambulance.Left:=Ambulance.Left;
Blaulicht1.Left:=Blaulicht1.Left;
Blaulicht2.Left:=Blaulicht2.Left;
Ambulance.Hide;
Blaulicht1.Hide;
Blaulicht2.Hide;
end;
end;
procedure Tinformatik.BlaulichtTimerTimer(Sender: TObject);
begin
if Blaulicht1.Brush.Color=clblue
then
begin
Blaulicht1.Brush.Color:=clwhite;
Blaulicht2.Brush.Color:=clblue;
end
else
begin
Blaulicht1.Brush.Color:=clblue;
Blaulicht2.Brush.Color:=clwhite;
end;
end;
procedure Tinformatik.HilfeClick(Sender: TObject);
begin
helpwindow.show;;
start:=0;
end;
procedure Tinformatik.Phase1Fahr();
begin
AV1Gruen.Brush.Color:=clgreen;
AV2Gruen.Brush.Color:=clgreen;
AV1Rot.Brush.Color:=clblack;
AV2Rot.Brush.Color:=clblack;
AV1Gelb.Brush.Color:=clblack;
AV2Gelb.Brush.Color:=clblack;
AH1Rot.Brush.Color:=clred;
AH2Rot.Brush.Color:=clred;
AH1Gelb.Brush.Color:=clblack;
AH2Gelb.Brush.Color:=clblack;
end;
procedure Tinformatik.Phase2Fahr();
begin
AV1Gruen.Brush.Color:=clblack;
AV2Gruen.Brush.Color:=clblack;
AV1Gelb.Brush.Color:=clyellow;
AV2Gelb.Brush.Color:=clyellow;
AH1Rot.Brush.Color:=clred;
AH2Rot.Brush.Color:=clred;
end;
procedure Tinformatik.Phase3Fahr();
begin
AV1Gelb.Brush.Color:=clblack;
AV2Gelb.Brush.Color:=clblack;
AV1Rot.Brush.Color:=clred;
AV2Rot.Brush.Color:=clred;
AH1Rot.Brush.Color:=clred;
AH2Rot.Brush.Color:=clred;
AH1Gelb.Brush.Color:=clyellow;
AH2Gelb.Brush.Color:=clyellow;
end;
procedure Tinformatik.Phase4Fahr();
begin
AH1Rot.Brush.Color:=clblack;
AH2Rot.Brush.Color:=clblack;
AH1Gelb.Brush.Color:=clblack;
AH2Gelb.Brush.Color:=clblack;
AH1Gruen.Brush.Color:=clgreen;
AH2Gruen.Brush.Color:=clgreen;
end;
procedure Tinformatik.Phase5Fahr();
begin
AH1Rot.Brush.Color:=clred;
AH2Rot.Brush.Color:=clred;
AH1Gelb.Brush.Color:=clyellow;
AH2Gelb.Brush.Color:=clyellow;
AH1Gruen.Brush.Color:=clblack;
AH2Gruen.Brush.Color:=clblack;
AH1Rot.Brush.Color:=clblack;
AH2Rot.Brush.Color:=clblack;
end;
procedure Tinformatik.Phase6Fahr();
begin
AV1Gelb.Brush.Color:=clyellow;
AV2Gelb.Brush.Color:=clyellow;
AH2Gelb.Brush.Color:=clblack;
AH1Gelb.Brush.Color:=clblack;
AV1Rot.Brush.Color:=clred;
AV2Rot.Brush.Color:=clred;
AH1Rot.Brush.Color:=clred;
AH2Rot.Brush.Color:=clred;
end;
procedure Tinformatik.OKClick(Sender: TObject);
begin
if RCode.Text='
0012-0100-0019-9600-0017-0500'
then
begin
RegL.Append('
REGISTERED');
RenameFile('
delphi31.ini','
Auto.txt');
RegL.SaveToFile('
Autotrial.txt');
RenameFile('
Auto.txt','
delphi31.ini');
Ok.Hide;
RCode.Hide;
ShowMeAll();
end;
end;
procedure Tinformatik.FormDestroy(Sender: TObject);
begin
RegL.Free;
end;
procedure Tinformatik.DatumUndFarbeTimer(Sender: TObject);
begin
Datzeit:=TimeToStr(Time)+'
'+DateToStr(Date);
end;
procedure Tinformatik.ShowMeAll();
begin
// Zeige mir Alles
StartButton.Show;
speedA1.Show;
speedA2.Show;
AV1Rot.Show;
AV1Gelb.Show;
AV1Gruen.Show;
AV2Rot.Show;
AV2Gelb.Show;
AV2Gruen.Show;
AH1Rot.Show;
AH1Gelb.Show;
AH1Gruen.Show;
AH2Rot.Show;
AH2Gelb.Show;
AH2Gruen.Show;
VStreet.Show;
HStreet.Show;
Ende.Show;
Hilfe.Show;
Auto1.Show;
Auto2.Show;
AV1.Show;
AV2.Show;
AH1.Show;
AH2.Show;
informatik.Height:=541;
informatik.Width:=804;
end;
end.