Guest User

Untitled

a guest
Mar 14th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.05 KB | None | 0 0
  1. program Pingpong;
  2. uses crt;
  3.  
  4. var
  5. x,y,color,kx,ky,i,pax:integer;
  6. klawiatura:char;
  7. koniec:boolean;
  8. label miejsce;
  9.  
  10.  procedure paletka();
  11. begin
  12. gotoxy(pax,25);write('===');
  13.  
  14.  
  15. if keypressed then
  16. begin
  17.  
  18. klawiatura:=readkey;
  19.  
  20. if klawiatura = #97 then
  21. begin
  22. if pax =1 then
  23. goto miejsce;
  24.  
  25. pax:=pax-1;
  26. end;
  27.  
  28. if klawiatura = #100 then
  29. begin
  30. if pax=77 then
  31. goto miejsce;
  32.  
  33. pax:=pax+1;
  34.  
  35. end;
  36.  miejsce:
  37. end;
  38.  
  39.  
  40. end;
  41.  
  42.  
  43.  
  44. procedure Pilka();
  45. begin
  46. textcolor(color);
  47. paletka();
  48. gotoxy(x,y);write('O');
  49. x:=x+kx;
  50. y:=y+ky;
  51. if x=80 then
  52. kx:=-1;
  53. if x=1 then
  54. kx:=1;
  55. if y=25 then
  56. ky:=-1;
  57. if y=5 then
  58. ky:=1;
  59. end;
  60.  
  61. procedure plansza();
  62. begin
  63.  
  64. for i:=1 to 80 do
  65. begin
  66. gotoxy(i,5);write('=');
  67. end;
  68. end;
  69.  
  70. procedure odbicie();
  71. begin
  72.  
  73. if y=25 then
  74. begin
  75.  
  76. if (x<pax) or (x>pax+3) then
  77. koniec:= true;
  78.  
  79. end;
  80.  
  81.  
  82. end;
  83.  
  84.  procedure koniecgry();
  85. begin
  86. if koniec = true then
  87. begin
  88. Gotoxy(45,8);write('Koniec Gry');
  89.  
  90. end;
  91. end;
  92.  
  93.  
  94. begin
  95. x:=1;
  96. y:=5;
  97. color:=6;
  98. kx:=1;
  99. ky:=1;
  100. pax:=37;
  101. koniec:=false
  102.  
  103. while koniec = false do
  104. begin
  105. clrscr;
  106. plansza();
  107. paletka();
  108. pilka();
  109. odbicie();
  110. delay(35);
  111. end;
  112. koniecgry();
  113. readkey;
  114.  
  115.  
  116. end.
Add Comment
Please, Sign In to add comment