Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 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();
  13. void sterowanie();
  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()
  68. {
  69. int wysokosc,x,y;
  70. char znak;
  71.  
  72.  
  73.  
  74.  
  75. system("cls");
  76.  
  77. int W, i, j;
  78.  
  79. for (i = wysokosc; i >= 1; i--)
  80. {
  81.  
  82. for (j = wysokosc; j >= 1 + i; j--)
  83. {
  84. cout << " ";
  85. }
  86.  
  87. cout << znak;
  88.  
  89. for (W = 1; W < i; W++)
  90. {
  91. cout << " ";
  92. }
  93. cout << znak;
  94. cout << "\n";
  95. }
  96.  
  97. for (i = 1; i <= wysokosc; i++)
  98. {
  99.  
  100. for (j = 1; j <= wysokosc - i; j++)
  101. {
  102. cout << " ";
  103. }
  104. cout << znak;
  105. for (W = 1; W < i; W++)
  106. {
  107. cout << " ";
  108. }
  109. cout << znak;
  110. cout << "\n";
  111. }
  112. sterowanie();
  113. _getch();
  114. }
  115.  
  116. void sterowanie(int x, int y , int klawisz)
  117. {
  118. int x, y, esq = EXIT_SUCCESS;
  119. int klawisz;
  120. do{
  121. switch (klawisz)
  122. {
  123.  
  124.  
  125. case 75: { x--; break; } // przesuniecie w lewo
  126. case 77: { x++; break; } // przesuniecie w prawo
  127. case 72: { y--; break; } // przesuniecie do gory
  128. case 80: { y++; break; } // przesuniecie do dolu
  129. }
  130.  
  131. } while (klawisz != esq);
  132.  
  133. getch();
  134.  
  135. }
  136.  
  137. void wczyt_dane(char znak, int wysokosc)
  138. {
  139. char znak;
  140. int wysokosc;
  141.  
  142. cout << "podaj znak ktorym chcesz rysowac figure : \n";
  143. cin >> znak;
  144. cout << endl;
  145.  
  146. 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".
  147. cin >> wysokosc;
  148.  
  149.  
  150.  
  151. }
  152.  
  153. int _tmain(int argc, _TCHAR* argv[])
  154. {
  155. char znak;
  156. int wysokosc;
  157.  
  158. Tresc_projektu();
  159.  
  160. cout << "\n\n\n";
  161.  
  162. wczyt_dane(znak, wysokosc);
  163. HideCursor();
  164.  
  165. rysuj();
  166.  
  167. _getch();
  168.  
  169. return 0;
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement