Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <cstdio>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. void FunkcjaRzad(int x,int size)
  9. {
  10. if (x < size/2)
  11. {
  12.  
  13. cout << "|";
  14. for (int i = 0; i < x; i++)
  15. {
  16. cout << " ";
  17. }
  18. cout << "\\";
  19.  
  20. for (int i = 0; i < (size-2) - 2 * x; i++)
  21. {
  22. cout << " ";
  23. }
  24. cout << "/";
  25.  
  26. for (int i = 0; i < x; i++)
  27. {
  28. cout << " ";
  29. }
  30. cout << "|";
  31. }
  32. else
  33. {
  34. cout << "|";
  35. for (int i = (size-1)-x; i > 0; i--)
  36. {
  37. cout << " ";
  38. }
  39. cout << "/";
  40. for (int i = 0; i < (x-(size/2))*2; i++)
  41. {
  42. cout << " ";
  43. }
  44. cout << "\\";
  45. for (int i = (size-1) - x; i > 0; i--)
  46. {
  47. cout << " ";
  48. }
  49. cout << "|";
  50. }
  51.  
  52. }
  53.  
  54. void rysuj(int pion,int poziom, int wielkosc)
  55. {
  56. for (int i = 0; i < pion; i++)
  57. {
  58. cout << endl;
  59.  
  60. }
  61.  
  62.  
  63. for (int i = 0; i < wielkosc; i++)//petla w dol
  64. {
  65. for (int j = 0; j < poziom; j++)
  66. {
  67. cout << " ";
  68. }
  69. FunkcjaRzad(i, wielkosc);
  70.  
  71.  
  72. cout << endl;
  73.  
  74.  
  75. }
  76.  
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. int main()
  87. {
  88.  
  89. char znak;
  90. int pion=0;
  91. int poziom=0;
  92. int wielkosc=2;
  93. rysuj(pion, poziom, wielkosc);
  94. while (1)
  95. {
  96. cin >> znak;
  97. switch (znak)
  98. {
  99. case 'w':
  100. if (pion>0)
  101. pion--;
  102.  
  103. break;
  104. case 's':
  105. pion++;
  106. break;
  107. case 'a':
  108. if (poziom > 0)
  109. poziom--;
  110. break;
  111. case 'd':
  112. poziom++;
  113. break;
  114. case 'p':
  115. if (wielkosc<64)
  116. wielkosc = wielkosc * 2;
  117. break;
  118. case '-':
  119. wielkosc = wielkosc / 2;
  120. break;
  121. default:
  122. cout << "zle polecenie";
  123. break;
  124. }
  125. system("cls");
  126. rysuj(pion, poziom, wielkosc);
  127.  
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. //cin.get();
  141. //return 0;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement