thieumao

Phím di chuyển

Apr 30th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.55 KB | None | 0 0
  1. uses crt;
  2. var
  3.   ch: char;
  4.   x,y,m: byte;
  5. begin
  6.   clrscr;
  7.   x:=10;
  8.   y:=10;
  9.   {x=80;y=25}
  10.   repeat
  11.     begin
  12.       clrscr;
  13.       gotoxy(x,y);
  14.       write('*');
  15.       {gotoxy(75,25);write(x:2,',',y:2);}
  16.       ch:=readkey;
  17.       if ord(ch)=72 then begin y:=y-1; if y<1  then y:=25; end;
  18.       if ord(ch)=80 then begin y:=y+1; if y>25 then y:=1;  end;
  19.       if ord(ch)=75 then begin x:=x-1; if x<1  then x:=80; end;
  20.       if ord(ch)=77 then begin x:=x+1; if x>80 then x:=1;  end;
  21.       {writeln(ch,' = ',ord(ch));}
  22.     end;
  23.   until ord(ch)=27;
  24. end.
Advertisement
Add Comment
Please, Sign In to add comment