﻿program Morskie_Batalii;
uses graphABC, ABCobjects;
var i, b:integer; xBall, yBall: integer; ball1:CircleABC; korabl1, config: RectangleABC; E: boolean;
//Движение
procedure keyDown (key:integer);
begin
if (key = vk_Right)then xBall:=xBall + 80;
if (key = vk_Left)then xBall:=xBall - 80;
if (key = vk_Up)then yBall:=yBall - 80;
if (key = vk_Down)then yBall:=yBall + 80;
begin
if (key = vk_F1) then korabl1:=RectangleABC.Create(xBall-40,yBall-40, 80, 80, clBlack);
if (key = vk_F2) then if (640 - xBall) >=80 then korabl1:=RectangleABC.Create(xBall-40,yBall-40, 160, 80, clBlack);
if (key = vk_F3) then if (640 - xBall) >=160 then korabl1:=RectangleABC.Create(xBall-40,yBall-40, 240, 80, clBlack);
if ((key = vk_F4) and E=true) then if (640 - xBall) >=240 then korabl1:=RectangleABC.Create(xBall-40,yBall-40, 320, 80, clBlack);
end;
end;
begin
//окно
SetWindowCaption ('Морские Баталии');
SetWindowIsFixedSize (true);
setwindowsize(900,560);
CenterWindow;
clearwindow(clCyan);
//Игровое поле
for i:=0 to 6 do
begin
line (0, i*80, windowWidth, i*80)
end;
for i:=0 to 8 do
begin
line (i*80, 0, i*80, windowHeight)
end;
config:=RectangleABC.Create(640,0,260,560,clBlue);
SetBrushColor (clWhite);
textout (735,5,'Примечания');
//Раздел шарика
xBall:= 40;
yBall:= 40;
ball1:=CircleABC.Create(40,40,40, clRed);
//Движение(к процедуре)
b:=0;
while(true) do
begin
onKeyDown:=keyDown;
ball1.MoveTo(xBall-40, yBall-40);
sleep(100);
b:=b+1;
if b=10 then
E:=false
else E:=true;
//Чтобы шарик не выходил за границы поля
if (xBall>640) then xBall:= 40;
if (xBall<0) then xBall:= windowWidth - 40;
if (yBall>560) then yBall:= 40;
if (yBall<0) then yBall:= windowHeight - 40;
end;
end.