ето паскаль.
что делают выделеные части?
срочно помогите пожалуста
Код:
unit game;
interface
uses crt;
function main(kolvo_zaicev:byte):boolean;
procedure aboyt_mi;
procedure help;
implementation
const
sLeft = #17;
sRight = #16;
sUp = #30;
sDown = #31;
sHead = '%';
sApple = '@';
kUp = #72;
kLeft = #75;
kDown = #80;
kRight = #77;
(type
TScreenSymbol = record
Symbol: char;
Color: byte;
end; ) -------------------вот етот раздел
var
Key, ScanKey: char;
Time: longint absolute $0040: $006C;
T: longint;
HeadX, HeadY, TailX, TailY: integer;
Direction: (dUp, dLeft, dDown, dRight); ---------- вот ета строска
Screen: array [0 .. 49, 0 .. 79] of TScreenSymbol absolute $B800: $0000;
Lost, Win: boolean;
oldTail: char;
x, y,ii,aa, c,ax: integer;
function main(kolvo_zaicev:byte):boolean;
begin
if ax=3 then ax:=0;
ax:=ax+1;
c:=0;
randomize;
TextMode(259);
ClrScr;
gotoxy(1,2);
for ii:=1 to 79 do
write('*');
gotoxy(1,2);
for ii:=1 to 48 do
writeln('*');
gotoxy(1,50);
for ii:=1 to 79 do
write('*');
for ii:=2 to 48 do
begin
gotoxy(80,ii);
writeln('*');
end;
HeadX := 40;
HeadY := 40;
TailX := 40;
TailY := 41;
Direction := dUp;
Screen[HeadY, HeadX].Symbol := sHead;
Screen[HeadY, HeadX].Color := 14;
Screen[TailY, TailX].Symbol := sUp;
Screen[TailY, TailX].Color := 2;
Screen[HeadY - 10, HeadX].Symbol := sApple;
Screen[HeadY - 10, HeadX].Color := 4;
Lost := false;
Win:=false;
repeat
if KeyPressed then begin
Key := ReadKey;
if Key = #0 then ScanKey := ReadKey
else ScanKey := #0;
end else begin
Key := #0;
ScanKey := #0;
end;
( while T = Time do;
T := Time ----------------- вот етот кусок
case ScanKey of
kUp: if Direction <> dDown then Direction := dUp;
kLeft: if Direction <> dRight then Direction := dLeft;
kDown: if Direction <> dUp then Direction := dDown;
kRight: if Direction <> dLeft then Direction := dRight;
end;
case Direction of
dUp: begin
Screen[HeadY, HeadX].Symbol := sUp;
Screen[HeadY, HeadX].Color := 2;
dec(HeadY);
if HeadY < 3 then Lost := True;
end;
dLeft: begin
Screen[HeadY, HeadX].Symbol := sLeft;
Screen[HeadY, HeadX].Color := 2;
dec(HeadX);
if HeadX < 2 then Lost := True;
end;
dDown: begin
Screen[HeadY, HeadX].Symbol := sDown;
Screen[HeadY, HeadX].Color := 2;
inc(HeadY);
if HeadY >= 48 then Lost := True;
end;
dRight: begin
Screen[HeadY, HeadX].Symbol := sRight;
Screen[HeadY, HeadX].Color := 2;
inc(HeadX);
if HeadX >= 78 then Lost := True;
end;
end;
case Screen[HeadY, HeadX].Symbol of
sUp, sLeft, sDown, sRight: Lost := True;
sApple: begin
c:=c+1;
if c = kolvo_zaicev then Win := True;
x := random(70)+5;
y := random(40)+5;
Screen[y, x].Symbol := sApple;
Screen[y, x].Color := 4;
gotoxy(1,1);
write('sedenie soba4ki: ',c-1,' iz ', kolvo_zaicev-1,' your level:',ax);
end;
else begin
oldTail := Screen[TailY, TailX].Symbol;
Screen[TailY, TailX].Symbol := ' ';
case oldTail of
sUp: dec(TailY);
sLeft: dec(TailX);
sDown: inc(TailY);
sRight: inc(TailX);
end;
end;
end;
Screen[HeadY, HeadX].Symbol := sHead;
Screen[HeadY, HeadX].Color := 14;
until (Key = #27) or Lost or Win;
textattr:=$09;
clrscr;
writeln(' -------------------');
Writeln(' -------------------');
if Lost then begin main:=false; WriteLn(' ||You have lost! ||'); end;
if Win then begin main:=true; WriteLn(' ||You win!!! ||'); end;
writeln(' -------------------');
writeln(' ||vash s4ot: ',c-1,'||');
writeln(' -------------------');
writeln(' ||your level: ',ax,' ||');
writeln(' -------------------');
writeln(' -------------------');
readln;
end;
begin
end.