Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <math.h>
  5. #include <time.h>
  6. #include "windows.h"
  7.  
  8. using namespace std;
  9.  
  10. void Tresc_projektu();
  11. void wczyt_dane();
  12. void rysuj(int x , int y);
  13. void sterowanie(int x, int y, int klawisz);
  14.  
  15. void gotoxy(int x, int y)
  16. {
  17. COORD c;
  18. c.X = x;
  19. c.Y = y;
  20. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
  21. }
  22.  
  23. int wherex()
  24. {
  25.  
  26. CONSOLE_SCREEN_BUFFER_INFO csbi;
  27. GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
  28. return csbi.dwCursorPosition.X;
  29. }
  30.  
  31. int wherey()
  32. {
  33. CONSOLE_SCREEN_BUFFER_INFO csbi;
  34. GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
  35. return csbi.dwCursorPosition.Y;
  36. }
  37.  
  38. void HideCursor()
  39. {
  40. ::HANDLE hConsoleOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
  41. ::CONSOLE_CURSOR_INFO hCCI;
  42. ::GetConsoleCursorInfo(hConsoleOut, &hCCI);
  43. hCCI.bVisible = FALSE;
  44. ::SetConsoleCursorInfo(hConsoleOut, &hCCI);
  45. }
  46.  
  47. void Tresc_projektu()
  48.  
  49. {
  50. cout << endl;
  51. cout << endl;
  52. cout << "Napisz program rysowania znakiem ASCII ponizszej figury." << endl;
  53. cout << "Program powinien umozliwic:" << endl;
  54. cout << "- Wybor znaku kodu ASCII;" << endl;
  55. cout << "- wczytanie poczatkowych rozmiarow figury;" << endl;
  56. cout << "- przesuwanie figury za pomoca strzalek;" << endl;
  57. cout << "- powiekszanie oraz zmniejszanie rozmiaru " << endl;
  58. cout << " figury za pomoca klawiszy + i -;" << endl;
  59. cout << "- ograniczenie przesuwania i rozmiarow figury" << endl;
  60. cout << " do obszaru ekranu;" << endl;
  61. cout << endl;
  62. cout << endl;
  63. cout << endl;
  64. cout << endl;
  65. }
  66.  
  67. void rysuj(int x, int y)
  68. {
  69. int wysokosc,x,y;
  70. char znak;
  71.  
  72.  
  73. system("cls");
  74.  
  75. int W, i, j;
  76.  
  77. for (i = wysokosc; i >= 1; i--)
  78. {
  79.  
  80. for (j = wysokosc; j >= 1 + i; j--)
  81. {
  82. cout << " ";
  83. }
  84.  
  85. cout << znak;
  86.  
  87. for (W = 1; W < i; W++)
  88. {
  89. cout << " ";
  90. }
  91. cout << znak;
  92. cout << "\n";
  93. }
  94.  
  95. for (i = 1; i <= wysokosc; i++)
  96. {
  97.  
  98. for (j = 1; j <= wysokosc - i; j++)
  99. {
  100. cout << " ";
  101. }
  102. cout << znak;
  103. for (W = 1; W < i; W++)
  104. {
  105. cout << " ";
  106. }
  107. cout << znak;
  108. cout << "\n";
  109. }
  110.  
  111. }
  112.  
  113. void sterowanie(int x, int y , char klawisz)
  114. {
  115. int x, y, esq = EXIT_SUCCESS;
  116. char klawisz;
  117. do{
  118. _getch();
  119. switch (klawisz)
  120. {
  121. case 75: { x--; break; } // przesuniecie w lewo
  122. case 77: { x++; break; } // przesuniecie w prawo
  123. case 72: { y--; break; } // przesuniecie do gory
  124. case 80: { y++; break; } // przesuniecie do dolu
  125. }
  126.  
  127. } while (klawisz != esq);
  128.  
  129. rysuj(x,y);
  130.  
  131. }
  132.  
  133. void wczyt_dane(char znak, int wysokosc)
  134. {
  135. char znak;
  136. int wysokosc;
  137.  
  138. cout << "podaj znak ktorym chcesz rysowac figure : \n";
  139. cin >> znak;
  140. cout << endl;
  141.  
  142. cout << "Podaj poczatkowa wyskosc figory (minimalnie 3) : \n"; //prosba o wprowadzenie poczatkowej wysokosci figury. minimalnie 3 ze wzgledow estetycznych. gdyby było mniej niz 3 to figura by nie przypominala odwroconej litery "k".
  143. cin >> wysokosc;
  144.  
  145.  
  146.  
  147. }
  148.  
  149. int _tmain(int argc, _TCHAR* argv[])
  150. {
  151. char znak;
  152. int wysokosc , x ,y;
  153.  
  154. Tresc_projektu();
  155.  
  156. cout << "\n\n\n";
  157.  
  158. wczyt_dane(znak, wysokosc);
  159. HideCursor();
  160. rysuj(x, y);
  161. _getch();
  162.  
  163. return 0;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement