SLIDE.PAS 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. Uses CRT;
  2. Var
  3. s1, s2 : string[50];
  4. c : char;
  5. len, position : byte;
  6. k : word;
  7. dir : integer;
  8. Begin
  9. dir := 0;
  10. k := 0;
  11. ClrScr;
  12. TextColor(7);
  13. GotoXY(5,8);
  14. Write('‚¢¥¤¨â¥ áâபã ');
  15. Readln(s1);
  16. len := length(s1) +1;
  17. ClrScr;
  18. GotoXY(10,2);
  19. Write('Stand : ');
  20. GotoXY(10,4);
  21. Write('Slide :');
  22. GotoXY(30,10);
  23. Write('Result : ');
  24. GotoXY(30,2);
  25. Write(s1);
  26. Position := 15;
  27. c := #12;
  28. repeat
  29. if keypressed then begin
  30. c := readkey;
  31. repeat
  32. k := random(15);
  33. TextColor(k);
  34. until (k <> 8) and (k <> 0);
  35. if c = #0 then c := readkey;
  36. case c of
  37. #77 : begin
  38. if length(s2) < len -1 then Begin
  39. insert(s1[1],s2,Length(s2) + 1);
  40. delete(s1,1,1);
  41. GotoXY(20,2);
  42. ClrEOL;
  43. GotoXY(30 + (len-length(s1)-1), 2);
  44. Write(s1);
  45. GotoXY(29,4);
  46. ClrEOL;
  47. GotoXY(30,4);
  48. Write(s1);
  49. end;
  50. end;
  51. #75 : begin
  52. if length (s2) > 0 then begin
  53. insert(s2[length(s2)],s1,1);
  54. GotoXY(30 + len - length(s1)-1,2);
  55. ClrEOL;
  56. Write(s1);
  57. GotoXY(30,4);
  58. ClrEOL;
  59. Write(s1);
  60. Delete(s2,length(s2),1);
  61. end;
  62. end;
  63. end;
  64. end;
  65. GotoXY(1,12);
  66. ClrEOL;
  67. GotoXY(position,12);
  68. Write(s2);
  69. repeat
  70. k := random(1000);
  71. until k > 10;
  72. Delay (k);
  73. if position < 2 then dir := 1;
  74. if position + length(s2) > 79 then dir := 0;
  75. if dir = 0 then dec(position)
  76. else inc(position);
  77. until c = #27;
  78. TextColor(7);
  79. ClrScr;
  80. end.