Напишите, пожалуйста, программу по которой в pascal будет выводиться анимация перекрестка, по которому проезжают две машины, одна из которых останавливается на светофоре, и когда загорается зеленый свет, она проезжает дальше. CРОЧНО!!!

Ответы

Ответ дал: Аноним
0
Код PascalABC 3.0

uses GraphABC, Crt;
Var
x,y,t,v1,v2:integer;
C:word;
Begin
Write('Введите время работы светофора:  ');
ReadLn(t);
Write('Введите скорость зелёной машины: ');
ReadLn(v1);
Write('Введите скорость красной машины: ');
ReadLn(v2);
LockDrawing;
Repeat
ClearWindow;
Case (C div t) mod 3 of
0:SetBrushColor(clGreen);
1:SetBrushColor(clYellow);
2:SetBrushColor(clRed);
End;
Circle(-30+(WindowWidth div 2),-40+(WindowHeight div 2),10);

Case (C div t) mod 3 of
2:SetBrushColor(clGreen);
1:SetBrushColor(clYellow);
0:SetBrushColor(clRed);
End;
Circle(-40+(WindowWidth div 2),30+(WindowHeight div 2),10);
if C<65535 then C:=C+1
else C:=0;

SetBrushColor(clMedGray);
FillRect(0,20+(WindowHeight div 2),WindowWidth,-20+(WindowHeight div 2));
FillRect(20+(WindowWidth div 2),0,-20+(WindowWidth div 2),WindowHeight);

SetBrushColor(clGreen);
FillRect(-13+(WindowWidth div 2),-40+y,13+(WindowWidth div 2),y);
if ((x+v1<=(WindowWidth div 2)-20)or(x-40>=(WindowWidth div 2)+20)) then x:=x+v1
else
   Begin
   if ((y-40>=20+(WindowHeight div 2))or(y<=(WindowHeight div 2)-20)) then
      Begin
      if ((C div t) mod 3 = 2)or(x>(WindowWidth div 2)-20) then x:=x+v1
      End
   End;

if x>=WindowWidth+40 then x:=0;
SetBrushColor(clRed);
FillRect(-40+x,13+(WindowHeight div 2),x,-13+(WindowHeight div 2));
if (y+v2<=(WindowHeight div 2)-20)or(y-40>=(WindowHeight div 2)+20) then y:=y+v2
else
   Begin
   if (x-40>=20+(WindowWidth div 2))or(x<=(WindowWidth div 2)-20) then
      Begin
      if ((C div t) mod 3 = 0)or(y>(WindowHeight div 2)-20) then y:=y+v2
      End
   End;

if y>=WindowHeight+40 then y:=0;
Redraw
Until false;

End.
Вас заинтересует