Модуль Graph Pascal, как сделать чтобы машинки не выходили за границы?
uses
GraphABC;
type
avto=class
private
x :integer;
y :integer;
public
constructor Create (xx,yy:integer);
Procedure Show;
procedure Move(dx,dy:integer);
end;
constructor avto.Create(xx, yy: integer);
begin
x:=xx;
y:=yy;
end;
procedure avto.Show;
begin
setpencolor(clBlack);
setbrushcolor(clGreen);
rectangle(x,y,x-80,y+40);
setbrushcolor(clskyBlue);
rectangle(x-80,y+10,x-105,y+25);
setbrushcolor(clBlue);
rectangle(x-80,y+25,x-105,y+40);
setbrushcolor(clBlack);
circle(x-20,y+40,10);
circle(x-93,y+40,10);
end;
procedure avto.Move(dx, dy: integer);
begin
x := x + dx;
y := y + dy;
end;
var
Automobil: array[1..4] of avto;
i: integer;
begin
SetWindowSize(660, 540);
for i:=1 to 4 do
begin
Automobil[i] := avto.Create(400, 230);
Automobil[i].Show;
end;
lockdrawing;
for i := 1 to 195 do
begin
clearwindow;
Automobil[1].Show;
Automobil[2].Show;
Automobil[3].Show;
Automobil[4].Show;
sleep(10);
Automobil[1].Move(0, -2);
Automobil[2].Move(-2, 0);
Automobil[3].Move(2, 0);
Automobil[4].Move(0, 2);
redraw
end;
end.