ex2.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. program example2;
  2. uses video,keyboard;
  3. Var
  4. P,PP,D : Integer;
  5. K: TKeyEvent;
  6. Procedure PutSquare (P : INteger; C : Char);
  7. begin
  8. VideoBuf^[P]:=Ord(C)+($07 shr 8);
  9. VideoBuf^[P+ScreenWidth]:=Ord(c)+($07 shr 8);
  10. VideoBuf^[P+1]:=Ord(c)+($07 shr 8);
  11. VideoBuf^[P+ScreenWidth+1]:=Ord(c)+($07 shr 8);
  12. end;
  13. begin
  14. InitVideo;
  15. InitKeyBoard;
  16. P:=0;
  17. PP:=-1;
  18. Repeat
  19. If PP<>-1 then
  20. PutSquare(PP,' ');
  21. PutSquare(P,'#');
  22. SetCursorPos(P Mod ScreenWidth,P div ScreenWidth);
  23. UpdateScreen(False);
  24. PP:=P;
  25. Repeat
  26. D:=0;
  27. K:=TranslateKeyEvent(GetKeyEvent);
  28. Case GetKeyEventCode(K) of
  29. kbdLeft : If (P Mod ScreenWidth)<>0 then
  30. D:=-1;
  31. kbdUp : If P>=ScreenWidth then
  32. D:=-ScreenWidth;
  33. kbdRight : If ((P+2) Mod ScreenWidth)<>0 then
  34. D:=1;
  35. kbdDown : if (P<(VideoBufSize div 2)-(ScreenWidth*2)) then
  36. D:=ScreenWidth;
  37. end;
  38. Until (D<>0) or (GetKeyEventChar(K)='q');
  39. P:=P+D;
  40. until GetKeyEventChar(K)='q';
  41. DoneKeyBoard;
  42. DoneVideo;
  43. end.