Program Kursovaya_rabota;
Uses GraphABC;
Type Dulo=record//запись дула танка
lefthighx:integer;
rightlowy:integer
end;
Chelovek=record//запись человека
coordx:integer;
coordy:integer
end;
Var a,b,a1,b1:integer;
The_Dulo

The_Victim:Chelovek;
Procedure Gusenicy;//рисуем гусеницы
Begin
setpenwidth(2);
setpencolor(cllime);
setbrushcolor(clpurple);
circle(120,160,10);
circle(130,160,10);
circle(140,160,10);
circle(150,160,10);
circle(160,160,10);
circle(170,160,10);
circle(180,160,10);
circle(190,160,10)
End;
Procedure Bashnya;//рисуем башню
Begin
setpenwidth(2);
setpencolor(cllime);
setbrushcolor(clteal);
drawpie(155,155,40,0,180);
fillpie(155,155,40,0,180)
End;
Procedure DrawDulo(var x:integer;var y:integer);//рисуем дуло
Begin
setpenwidth(2);
setpencolor(cllime);
setbrushcolor(clteal);
Rectangle(x+145,y+80,x+165,y+130)
End;
Procedure DrawVictim (var x1:integer;var y1:integer);//рисуем человека
Begin
setpencolor(clpink);
setbrushcolor(clpink);
circle(x1+350,y1+90,15);
setpencolor(clblack);
setbrushcolor(clwhite);
circle(x1+340,y1+85,3);
circle(x1+360,y1+85,3);
setpixel(x1+340,y1+85,clblack);
setpixel(x1+360,y1+85,clblack);
Line(x1+345,y1+100,x1+355,y1+100);
setpenwidth(2);
setpixel(x1+350,y1+90,clblack);
Line(x1+350,y1+105,x1+350,y1+150);
Line(x1+350,y1+120,x1+340,y1+130);
Line(x1+350,y1+120,x1+360,y1+130);
Line(x1+350,y1+150,x1+340,y1+160);
Line(x1+350,y1+150,x1+360,y1+160);
End;
Procedure KeyDown(key:integer);//отжатие клавиш управления дулом и человека
Var x0,y0,r1:integer;
Begin
x0:=The_Dulo.lefthighx+155;
y0:=The_Dulo.rightlowy+105;
Lockdrawing;
Clearwindow;
case key of
VK_Up:begin//нажатие на клавишу вверх
r1:=round(sqrt(sqr(The_Dulo.lefthighx-x0)+sqr(The_Dulo.rightlowy-y0)));
The_Dulo.lefthighx:={The_Dulo.lefthighx-10}round(x0+r1*cos(pi/6));
DrawDulo(The_Dulo.lefthighx,The_Dulo.rightlowy);
Gusenicy;
Bashnya;
DrawVictim(The_Victim.coordx,The_Victim.coordy)
end;
VK_Down:begin//нажатие на клавишу вниз
The_Dulo.lefthighx:=The_Dulo.lefthighx+10;
The_Dulo.rightlowy:=The_Dulo.rightlowy+5;
DrawDulo(The_Dulo.lefthighx,The_Dulo.rightlowy);
Gusenicy;
Bashnya;
DrawVictim(The_Victim.coordx,The_Victim.coordy)
end;
VK_Left:begin//нажатие на клавишу влево
The_Victim.coordx:=The_Victim.coordx-10;
DrawDulo(The_Dulo.lefthighx,The_Dulo.rightlowy);
Gusenicy;
Bashnya;
DrawVictim(The_Victim.coordx,The_Victim.coordy);
end;
VK_Right:begin//нажатие на клавишу вправо
The_Victim.coordx:=The_Victim.coordx+10;
DrawDulo(The_Dulo.lefthighx,The_Dulo.rightlowy);
Gusenicy;
Bashnya;
DrawVictim(The_Victim.coordx,The_Victim.coordy);
end;
end;
redraw;
sleep(80)
End;
Begin
The_Victim.coordx:=a1;
The_Victim.coordy:=b1;
The_Dulo.lefthighx:=a;
The_Dulo.rightlowy:=b;
Gusenicy;
DrawDulo(The_Dulo.lefthighx,The_Dulo.rightlowy);
Bashnya;
DrawVictim(The_Victim.coordx,The_Victim.coordy);
OnKeyDown:=KeyDown;
End.