Procedure PrintArena; var i,j,y:Byte; Begin textcolor(darkgray); y:=1; GotoXY(1,y); For i:=1 to 80 do write(chr(219)); For i:=1 to 19 do Begin inc(y); Gotoxy(1,y); write(chr(219)); For j:=1 to 78 do write(' '); write(chr(219)); End; inc(y); Gotoxy(1,y); For i:=1 to 80 do write(chr(219)); End;
Procedure PrintXY(x,y:integer; s:string); Var x0,y0:integer; Begin x0:= WhereX; y0:= WhereY; GotoXY(x,y); Write(s); GotoXY(x0,y0); End;
Function Interior(x,y:Integer): Integer; Begin If (x>=WindMinX+1) then x1:=x1-1; if(x<=WindMaxX-1) then x1:=x1+1; if (y>=WindminY+1) then y1:=y1-1; if(y<=WindmaxY-5) then y1:=y1+1; Interior:=1;
If c=1 Then Begin c:=0; perm:=1; bx:=Random(78)+2; by:=Random(19)+2; Gotoxy(bx,by); textcolor(red); Write(chr(3)); End;
If (boost=50) and (bperm=1) Then Begin bperm:=0; sx:= Random(78)+2; sy:= Random(19)+2; textcolor(LightBlue); PrintXY(sx, sy, chr(24)); End;
If KeyPressed Then Begin Case Readkey of #0: Begin key:= Readkey; Case key of Up: Begin dx:= 0; dy:=-1; End; Down: Begin dx:= 0; dy:= 1; End; Left: Begin dx:=-1; dy:= 0; End; Right: Begin dx:= 1; dy:= 0; End; End; End; Stop: Begin dx:=0; dy:=0; End; Escape: Begin Break; End; End; End;
If ((bperm=0) and (time=150)) or ((a=1) and (time=540)) Then Begin If (a=1) and(time =540) then Begin time:=0; a:=0; PrintXY(2, WindMaxY-2,' '); speed:=40; zspeed:=2; End Else Begin time:=0; gotoxy(sx,sy); Write(' '); bperm:=1; sx:=0; sy:=0; End; End; x1:= x+dx; y1:= y+dy; If (Interior (x1,y1) = 1) Then Begin if (bperm=0)or(a=1) then inc(time); boost:=Random(1000); textColor(lightgray); PrintXY(x,y, ' '); x:=x1; y:=y1; PrintXY(x,y,'*'); If (x=sx) and (y=sy) Then Begin bperm:=1; speed:=20; zspeed:=5; textcolor(lightblue); PrintXY(2, WindMaxY-2,'BOOST!'); a:=1; End; If (x=bx) and (y=by) Then Begin c:=1; if (perm=0) and (counter<2) then counter:=0 else if (perm=0) then counter:=counter-2 Else inc(counter); End; GotoXY(65,WindMaxY-1); write('(', x:3,' ;', y:3, ')'); GotoXY(25,WindMaxY-1); write(counter:3,'/100'); End; inc(q); delay(speed); If(q mod zspeed =1) then Begin if q =1000 then q:=0; textcolor(lightgreen); If (zx=bx) and (zy=by) Then Begin PrintXY(zx,zy, chr(15)); perm:=0; End Else PrintXY(zx,zy, ' '); If (y1 < zy) Then Begin dec(zy); PrintXY(zx,zy,'$'); End Else If (x1 > zx) Then Begin inc(zx); PrintXY(zx,zy,'$'); End Else If (y1 > zy) Then Begin inc(zy); PrintXY(zx,zy,'$'); End Else If (x1 < zx) Then Begin dec(zx); PrintXY(zx,zy,'$'); End; End;
If (x1=zx) and (y1=zy) then GO:=1; Until (counter=100) or (GO=1); ClrScr; CursorOn; if GO=1 then Begin gotoxy(37,11); textcolor(Red); WRITELN('GAME OVER'); End Else Begin gotoxy(37,11); textcolor(Lightgreen); WRITELN('Congratulation!!! you WON'); end; readkey; End.