#include #include #include //We use Sleep() as a delay function... #define MaxMon 10 #define MaxObj 10 #define X Conan.posX #define Y Conan.posY #define Health Conan.health #define Magic Conan.magic #define Money Conan.money #define Dir Conan.direction #define Row 18 #define Col 64 #define MaxCommand 12 using namespace std; class Screen { public: int getStage(); void setStage(int); void refresh(); protected: int stage; }scr; int Screen::getStage() { return stage; } void Screen::setStage(int new_stage) { stage=new_stage; } class Hero { public: unsigned int posY,posX,health,magic,money,direction; }Conan; class Monster //to make better constructor for i,j and default exists value { public: bool exists; unsigned int posX,posY,health; //virtual void Run(int)=0; //=0!!! virtual void Mpe() const {cout << "monster edw" <posX=j; // Monsters[init_mon]->posY=i; // Monsters[init_mon]->exists=true; init_mon++; } /* //togo if(ch=='m') { Monsters[init_mon]=new Magician; Monsters[init_mon]->posX=j; Monsters[init_mon]->posY=i; Monsters[init_mon]->exists=true; init_mon++; } if(ch=='s') { Monsters[init_mon]=new Seeker; Monsters[init_mon]->posX=j; Monsters[init_mon]->posY=i; Monsters[init_mon]->exists=true; init_mon++; } if(ch=='$') { Objects[init_obj]=new Euro; Objects[init_obj]->posX=j; Objects[init_obj]->posY=i; Objects[init_obj]->exists=true; init_obj++; } if(ch=='+') { Objects[init_obj]=new MedKit; Objects[init_obj]->posX=j; Objects[init_obj]->posY=i; Objects[init_obj]->exists=true; init_obj++; } */ } fin.get(ch); if(ch!='\n') //eat the EOF character cout<<"SHIT"; //to go } fin.close(); NumOfMon=init_mon; NumOfObj=init_obj; int counter = 0; //togo Monsters = new Monster[NumOfMon]; //togo //Monsters = new Monster[counter]; //togo for (i=0;i<=Row-1;i++) //suppose that there are not 2 monsters in the same position (counter in if) { for (j=0;j<=Col-1;j++) { if (map[i][j]=='s') { Monsters[counter] = new Seeker; Monsters++; } if (map[i][j]=='m') { Monsters[counter] = new Magician; counter++; } if (map[i][j]=='g') { Monsters[counter] = new Guard; counter++; } } } //togo the up Monster* pointer; for (i=0;iMpe(); } } Monster * Dungeon::FindMonster(int x,int y) { for(int i=0;iposX==x && Monsters[i]->posY==y && Monsters[i]->exists==true) { cout<<"TO ZHTOUMENO MONSTER HTAN TO "<posX==x && Objects[i]->posY==y && Objects[i]->exists==true) return Objects[i]; } } void Screen::refresh() { system("cls"); for(int i=0;i<=Row-1;i++) { for(int j=0;j<=Col-1;j++) cout<>command;*/ while(1) { scr.refresh(); cout<<"|Make your move...: "; cin.get(command,MaxCommand); cin.ignore(); //"eats" the newline character that get() leaves in the buffer bool Valid_Command = false; if(string(command)=="exit") return 0; if(string(command)=="up") { if((Stage[cur_stage].map[Y-1][X])!='#') { Stage[cur_stage].map[Y][X]=' '; Y--; Stage[cur_stage].map[Y][X]='h'; Valid_Command = true; } else continue; } if(string(command)=="down") { if((Stage[cur_stage].map[Y+1][X])!='#') { Stage[cur_stage].map[Y][X]=' '; Y++; Stage[cur_stage].map[Y][X]='h'; Valid_Command = true; } else continue; } if(string(command)=="left") { if((Stage[cur_stage].map[Y][X-1])!='#') { Stage[cur_stage].map[Y][X]=' '; X--; Stage[cur_stage].map[Y][X]='h'; Valid_Command = true; } else continue; } if(string(command)=="right") { if((Stage[cur_stage].map[Y][X+1])!='#') { Stage[cur_stage].map[Y][X]=' '; X++; Stage[cur_stage].map[Y][X]='h'; Valid_Command = true; } else continue; } if (!Valid_Command) //check validation of command continue; for(i=0;iRun(i); for(i=0;iRun(i); } //beware to delete all instances!!! cout<