Program SeaWar; Uses Graph,Crt; Type Rec=Record ranen,korab:boolean; xx,yy:integer; end; Thor=array [1..14] of char; Tver=array [1..14] of String[2]; Const hor:Thor=('A','B','C','D','E','F','G','H','I','J','K','L','M','N'); var Driver,r,e, cx1,cy1,cx2, x1,x2,y1,y2, i,j,k: integer; ch: char; Xasp,Yasp,XY: word; Ver: Tver; st: string[2]; level: byte; p1,p2: pointer; Comp_CooR, Pl_CooR: array [1.14,1..14] of Rec; Procedure Draw_Line; begin SetWriteMode(XorPut); SetLineStyle(0,0,1); Line(cx1,cy1,cx2,cy1); Line(cx1,cy1+k,cx2,cy1+k); Cy1:=Cy1+k; ch:=#0; end; BEGIN level:=1; Driver:=Detect; InitGraph(Driver,r,''); e:=GraphResult; if e<>grok then begin WriteLn(GraphErrorMsg(e)); ReadLn; halt; end else begin {======================Zastavka i vibor rezima========================} SetBKColor(black); SetColor(white); SetLineStyle(0,0,1); SetFillStyle(1,red); FillEllipse(GetMaxX div 2,70,49,49); Circle(GetMaxX div 2,70,50); Circle(GetMaxX div 2,70,20); Line(GEtMaxX div 2,20,GEtMaxX div 2,120); Line(GEtMaxX div 2-50,70,GEtMaxX div 2+50,70); SetColor(red); SettextStyle(4,0,7); OutTextXY(210,85,'Sea'); OutTextXY(340,85,'Battle'); SetWriteMode(XorPut); SetColor(10); SetTextStyle(7,0,5); OutTextXY(270,190,'Play'); OutTextXy(270,260,'Level'); OutTextXY(270,330,'Exit'); cx1:=250; cx2:=380; cy1:=245; SetColor(red); Line(cx1,cy1,cx2,cy1); {--1-}REPEAT begin if ch=#0 then repeat Ch:=Readkey; until ch in [#80,#72,#13]; if ch=#72 then if cy1<>245 then begin k:=-70; Draw_Line; end else repeat ch:=readkey; until ch in [#13,#80] else if ch=#80 then if cy1<>245+2*70 then begin k:=70; Draw_Line; end else repeat ch:=readkey; until ch in [#13,#72] else; if (ch=#13) then if cy1=245+70 then begin xy:=ImageSize(cx1,180,cx2+150,390); GetMem(p1,xy); GetImage(cx1,180,cx2+150,490,p1^); PutImage(cx1,180,p1^,XorPut); SetColor(10); SetTextStyle(7,0,5); OutTextXY(270,190,'Easy'); OutTextXy(270,260,'Medium'); OutTextXY(270,330,'Hard'); cx1:=250; cx2:=380; cy1:=245; SetColor(red); Line(cx1,cy1,cx2,cy1); ch:=#0; {--2--} Repeat begin if ch=#0 then repeat Ch:=Readkey; until ch in [#27,#80,#72,#13]; if ch=#72 then if cy1<>245 then begin k:=-70; Draw_Line; end else repeat ch:=readkey; until ch in [#13,#80,#27] else if ch=#80 then if cy1<>245+2*70 then begin k:=70; Draw_Line; end else repeat ch:=readkey; until ch in [#13,#72,#27] else if ch=#27 then PutImage(cx1,180,p1^,NormalPut) else if ch=#13 then level:=(cy1-245) div 70+1 else; end; {--2--} Until ch=#13; PutImage(cx1,180,p1^,NormalPut); SetWriteMode(CopyPut); cy1:=245+70; line(cx1,cy1,cx2,cy1); ch:=#0; end else if cy1=245+140 then halt else else; end; {--1-}UNTIL (ch=#13) and (cy1=245); {-+++===========================End of Vibor Rezima=================} if level=1 then level:=0 else if level=2 then level:=2 else if level=3 then level:=4; FreeMem(p1,XY); for i:=1 to 14 do begin Str(i,st); Ver[i]:=st; end; GetAspectRatio(Xasp,Yasp); XY:=Round(yasp/Xasp); SetBkColor(6); SetColor(white); SetLineStyle(0,0,3); ClearDevice; Rectangle(30,110,30+(200+20*level)*XY,310+20*level); SetFillStyle(1,blue); Bar(30,110,30+(200+20*level)*XY,310+20*level); Rectangle(340,110,340+(200+20*level)*XY,310+20*level); Bar(340,110,340+(200+20*level)*XY,310+20*level); SetTextStyle(0,0,1); for k:=1 to 10+level do begin OutTextXY(15+20*k,90,hor[k]); OutTextXY(325+20*k,90,hor[k]); OutTextXY(10,95+20*k,ver[k]); OutTextXY(320,95+20*k,ver[k]); end; SetColor(10); SettextStyle(7,0,6); OutTextXY(200,10,'Sea Battle'); SetTextStyle(4,0,5); SetColor(10); OutTextXy(80,310+20*level,'Player'); OutTextXy(370,310+20*level,'Computer'); SetLineStyle(3,0,1); for k:=1 to 9+level do begin line(30,110+20*k,30+(200+20*level)*XY,110+20*k); line(339,110+20*k,340+(200+20*level)*XY,110+20*k); line(30+20*k,110,30*Xy+20*k,310+20*level); line(340+20*k,110,340*Xy+20*k,310+20*level); end; SetViewPort(31,111,29+(200+20*level)*XY,309+20*level,clipOn); Readln; end; CloseGraph; END.