Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- class cMapa;
- class Element
- {
- protected:
- int passable;
- int elementX;
- int elementY;
- int kolor;
- char znak;
- cMapa *Gra;
- public:
- Element(int x, int y, char oznaczenie,int pass, int kolorek, cMapa *_Gra)
- :Gra(_Gra)
- {
- passable=pass;
- elementX=x;
- elementY=y;
- znak=oznaczenie;
- kolor=kolorek;
- }
- Element(const Element &el){
- passable=el.passable;
- znak=el.znak;
- kolor=el.kolor;
- }
- void zamiana(){
- }
- };
- class cMapa
- {
- protected:
- int Width, Height;
- Element ***Mapa;
- public:
- cMapa(int _Width, int _Height)
- :Width(_Width),Height(_Height)
- {
- _COORD coord;
- coord.X = 60;
- coord.Y = 130;
- _SMALL_RECT Rect;
- Rect.Top = 0;
- Rect.Left = 0;
- Rect.Bottom = Height+4;
- Rect.Right = Width+2;
- HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE); // Get Handle
- SetConsoleScreenBufferSize(Handle, coord); // Set Buffer Size
- SetConsoleWindowInfo(Handle, TRUE, &Rect); // Set Window Size
- if(Width <= 0)
- Width = 1;
- if(Height <= 0)
- Height = 1;
- Mapa = new Element**[Height];
- for(int i = 0; i<Height; i++)
- Mapa[i] = new Element*[Width];
- }
- ~cMapa()
- {
- for(int i = 0; i<Height; i++)
- delete [] Mapa[i];
- delete [] Mapa;
- }
- void wyswietl()
- {
- HANDLE hConsole;
- hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- int kolor;
- for(int i = 0; i<Height; i++)
- {
- for(int y = 0; y<Width; y++)
- if(i==0||i==Height-1||y==0||y==Width-1)
- {
- kolor=7;
- SetConsoleTextAttribute(hConsole, kolor);
- std::cout<<"#";
- }
- else{
- kolor=10;
- SetConsoleTextAttribute(hConsole, kolor);
- std::cout<<".";
- }
- std::cout<<std::endl;
- }
- }
- int getMapa(int x, int y){
- return 0;
- }
- void setMapa(int x, int y, Element *Arg){
- Mapa[x][y]=Arg;
- }
- };
- class Gracz : public Element
- {
- public:
- Gracz(cMapa *_Gra)
- :Element(59,20,'@',0,14,_Gra)
- {
- // _Gra->setMapa(59,20,);
- }
- bool sprawdz(int dx, int dy)
- {
- return true;
- }
- void ruch(int dx, int dy){
- }
- };
- void gotoxy( int height, int width )
- {
- COORD coord;
- coord.X = width;
- coord.Y = height;
- SetConsoleCursorPosition(
- GetStdHandle( STD_OUTPUT_HANDLE ),
- coord
- );
- }
- int main()
- {
- //int kierunek;
- //SetWindow(120,50);
- Element Trawa(1,0,0,',',10,_Gra);
- cMapa obiekt(60,40);
- Gracz player();
- obiekt.wyswietl();
- /*
- while(true){
- kbhit();
- kierunek=getch();
- switch(kierunek)
- {
- case 72: //gora
- if(player.sprawdz(0,-1)){
- player.ruch(0,-1);
- }
- break;
- case 75: //lewo
- if(player.sprawdz(-1,0)){
- player.ruch(-1,0);
- }
- break;
- case 77: //prawo
- if(player.sprawdz(1,0)){
- player.ruch(1,0);
- }
- break;
- case 80: //dol
- if(player.sprawdz(0,1)){
- player.ruch(0,1);
- }
- break;
- case 27: //esc
- gotoxy(41,0);
- std::cout<<"The end"<<std::endl;
- return 0;
- }}*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement