Advertisement
Guest User

gg

a guest
May 27th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <cstdlib>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. class cMapa;
  10.  
  11. class Element
  12. {
  13. protected:
  14.  
  15. int passable;
  16. int elementX;
  17. int elementY;
  18. int kolor;
  19. char znak;
  20. cMapa *Gra;
  21.  
  22. public:
  23.  
  24.  
  25. Element(int x, int y, char oznaczenie,int pass, int kolorek, cMapa *_Gra)
  26. :Gra(_Gra)
  27. {
  28. passable=pass;
  29. elementX=x;
  30. elementY=y;
  31. znak=oznaczenie;
  32. kolor=kolorek;
  33. }
  34.  
  35. Element(const Element &el){
  36. passable=el.passable;
  37. znak=el.znak;
  38. kolor=el.kolor;
  39. }
  40.  
  41. void zamiana(){
  42.  
  43.  
  44. }
  45. };
  46.  
  47.  
  48. class cMapa
  49. {
  50. protected:
  51. int Width, Height;
  52. Element ***Mapa;
  53.  
  54. public:
  55. cMapa(int _Width, int _Height)
  56. :Width(_Width),Height(_Height)
  57. {
  58.  
  59. _COORD coord;
  60. coord.X = 60;
  61. coord.Y = 130;
  62. _SMALL_RECT Rect;
  63. Rect.Top = 0;
  64. Rect.Left = 0;
  65. Rect.Bottom = Height+4;
  66. Rect.Right = Width+2;
  67. HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE); // Get Handle
  68. SetConsoleScreenBufferSize(Handle, coord); // Set Buffer Size
  69. SetConsoleWindowInfo(Handle, TRUE, &Rect); // Set Window Size
  70.  
  71. if(Width <= 0)
  72. Width = 1;
  73. if(Height <= 0)
  74. Height = 1;
  75.  
  76. Mapa = new Element**[Height];
  77. for(int i = 0; i<Height; i++)
  78. Mapa[i] = new Element*[Width];
  79.  
  80. }
  81.  
  82.  
  83. ~cMapa()
  84. {
  85. for(int i = 0; i<Height; i++)
  86. delete [] Mapa[i];
  87. delete [] Mapa;
  88. }
  89.  
  90. void wyswietl()
  91. {
  92. HANDLE hConsole;
  93. hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  94. int kolor;
  95. for(int i = 0; i<Height; i++)
  96. {
  97. for(int y = 0; y<Width; y++)
  98.  
  99. if(i==0||i==Height-1||y==0||y==Width-1)
  100. {
  101.  
  102. kolor=7;
  103. SetConsoleTextAttribute(hConsole, kolor);
  104. std::cout<<"#";
  105. }
  106. else{
  107. kolor=10;
  108. SetConsoleTextAttribute(hConsole, kolor);
  109. std::cout<<".";
  110. }
  111. std::cout<<std::endl;
  112. }
  113. }
  114.  
  115. int getMapa(int x, int y){
  116.  
  117.  
  118. return 0;
  119. }
  120. void setMapa(int x, int y, Element *Arg){
  121.  
  122. Mapa[x][y]=Arg;
  123.  
  124. }
  125.  
  126.  
  127. };
  128.  
  129.  
  130. class Gracz : public Element
  131. {
  132. public:
  133. Gracz(cMapa *_Gra)
  134. :Element(59,20,'@',0,14,_Gra)
  135. {
  136. // _Gra->setMapa(59,20,);
  137.  
  138. }
  139.  
  140. bool sprawdz(int dx, int dy)
  141. {
  142.  
  143.  
  144. return true;
  145. }
  146.  
  147. void ruch(int dx, int dy){
  148.  
  149.  
  150.  
  151. }
  152.  
  153.  
  154.  
  155. };
  156.  
  157. void gotoxy( int height, int width )
  158. {
  159. COORD coord;
  160. coord.X = width;
  161. coord.Y = height;
  162. SetConsoleCursorPosition(
  163. GetStdHandle( STD_OUTPUT_HANDLE ),
  164. coord
  165. );
  166. }
  167.  
  168.  
  169. int main()
  170. {
  171. //int kierunek;
  172. //SetWindow(120,50);
  173.  
  174. Element Trawa(1,0,0,',',10,_Gra);
  175. cMapa obiekt(60,40);
  176. Gracz player();
  177. obiekt.wyswietl();
  178. /*
  179. while(true){
  180. kbhit();
  181. kierunek=getch();
  182. switch(kierunek)
  183. {
  184. case 72: //gora
  185. if(player.sprawdz(0,-1)){
  186. player.ruch(0,-1);
  187.  
  188.  
  189. }
  190. break;
  191. case 75: //lewo
  192. if(player.sprawdz(-1,0)){
  193. player.ruch(-1,0);
  194.  
  195.  
  196.  
  197. }
  198. break;
  199. case 77: //prawo
  200. if(player.sprawdz(1,0)){
  201. player.ruch(1,0);
  202.  
  203.  
  204.  
  205. }
  206. break;
  207.  
  208. case 80: //dol
  209. if(player.sprawdz(0,1)){
  210. player.ruch(0,1);
  211.  
  212.  
  213. }
  214. break;
  215.  
  216. case 27: //esc
  217. gotoxy(41,0);
  218. std::cout<<"The end"<<std::endl;
  219. return 0;
  220. }}*/
  221. return 0;
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement