program mang; uses crt; var rx, ry:integer; siht, x, y:integer; saht,c:string; lopp:boolean; kiirusx, kiirusy, kohtx, kohty:real; begin clrscr; randomize; rx:=random(80)+1; ry:=random(25)+1; kohtx:=1; kohty:=24; x:=1; y:=24; kiirusx:=0.3; kiirusy:=-0.3; lopp:=false; repeat siht:=random(4); if(siht=0) and (ry=1) then siht:=2; if(siht=1) and (rx=80) then siht:=3; if(siht=2) and (ry=25) then siht:=0; if(siht=3) and (rx=1) then siht:=1; case siht of 0:ry:=ry-1; 1:rx:=rx+1; 2:ry:=ry+1; 3:rx:=rx-1; end; textcolor(blue); gotoxy(rx, ry); write('Ï'); delay(100); if keypressed then begin begin c:=readkey; if c=chr(0) then begin c:=readkey; if (c='K') then if kiirusx<0 then kiirusx:=kiirusx-0.2 else kiirusx:=-0.2; if (c='M') then if kiirusx>0 then kiirusx:=kiirusx+0.2 else kiirusx:=0.2; if (c='H') then if kiirusy<0 then kiirusy:=kiirusy-0.2 else kiirusy:=-0.2; if (c='P') then if kiirusy>0 then kiirusy:=kiirusy+0.2 else kiirusy:=0.2; end; end; end; textcolor(black); gotoxy(x, y); write('$'); kohty:=kohty+kiirusy; kohtx:=kohtx+kiirusx; x:=round(kohtx); y:=round(kohty); if y=0 then lopp:=true; if x=81 then lopp:=true; if y=26 then lopp:=true; if x=0 then lopp:=true; textcolor(green); gotoxy(x, y); write('$'); textcolor(black); gotoxy(rx, ry); write('Ï'); until (lopp) or ((x=rx) and (y=ry)); textcolor(yellow); if lopp then write('M„ng on l„bi. Sa said p„he!! Loll!!') else write('Tubli! Sa väitsid!!'); readln; textcolor(green); end.