Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- // ||
- //=================Правила=====================
- //Игрок - может ходить, если в 3-х клетках после хода есть герой, он его убивает
- //Палач - может ходить, если в 3-х клетках после хода есть игрок, он его притягивает
- // (не убивает)
- //Воин - может ходить, если в 3-х после хода есть игрок, он его убивает
- //
- //Цель игры - выжить 50 ходов или убить всех героев.
- //================ОБОЗНАЧЕНИЯ==================
- // P - Player (Игрок)
- // E - Executioner (Палач)
- // W - Warrior (Воин)
- using namespace std;
- void field(int xp, int yp, int xe, int ye/* int xw, int yw*/)
- {
- string field [22][21]; //
- for (int y=21; y>0; --y)
- {
- for (int x=1; x<21; ++x)
- {
- if (y==21)
- {
- if (x<10)
- cout << x << " ";
- else
- cout <<x;
- }
- else
- if ((xp==x)&&(yp==y))
- field[x][y]= "P ";
- else
- if ((xe==x)&&(ye==y))
- field[x][y]= "E ";
- // else
- // if ((xw==x)&&(yw==y))
- // field[x][y]= "W ";
- else
- field[x][y]= ". ";
- cout << field[x][y];
- }
- cout << " y = " << y << endl;
- }
- }
- class P
- {
- int x = 10;
- int y = 2;
- bool z = 0;
- public:
- int moveP (char move/*, int z*/)
- {
- if ((move == 'w')||(move == 's'))
- {
- if (z==false)
- {
- move == 'w' ? ++y : --y;
- y>20 ? --y : (y<1 ? ++y :y);
- z=true;
- cout << "y = " <<y<<endl;
- return y;
- }
- else
- {
- z=false;
- cout << "x = " <<x<<endl;
- return x;
- }
- }
- if ((move == 'd')||(move == 'a'))
- {
- if (z==false)
- {
- z=true;
- cout << "y = " <<y<<endl;
- return y;
- }
- else
- {
- move == 'd' ? ++x : --x;
- x>20 ? --x : (x<1 ? ++x:x);
- z=false;
- cout << "x = " <<x<<endl;
- return x;
- }
- }
- }
- };
- class bot
- {
- };
- class E : public bot //executioner
- {
- int x=2;
- int y=19;
- int move=0;
- public:
- int moveE(bool z)
- {
- if (z==1)
- {
- move = 1 + rand ()%4;
- if (move <3)
- {
- move == 1 ? ++y : --y;
- y>20 ? y-=2 : (y<1 ? y+=2 :y);
- }
- return y;
- }
- else
- {
- if (move > 2)
- {
- move == 3 ? ++x : --x;
- x>20 ? x-=2 : (x<1 ? x+=2 :x);
- }
- return x;
- }
- }
- };
- int main()
- {
- srand(time(NULL));
- int xe=2;
- int ye=19;
- int xp = 10;
- int yp = 2;
- P player;
- E executioner;
- char move;
- cout << "x = " <<xp<<endl;
- cout << "y = " <<yp<<endl;
- field (xp,yp,xe,ye);
- for (;;)
- {
- cin >> move;
- system("cls");
- field ( player.moveP(move), player.moveP(move), executioner.moveE(0), executioner.moveE(1) );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement