Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<Windows.h>
- #include<iostream>
- #include<conio.h>
- using namespace std;
- void Design(char Mat[][80])
- {
- for (int c = 0; c < 80; c++)
- {
- Mat[0][c] = 205;
- Mat[23][c] = 205;
- }
- for (int r = 1; r < 23; r++)
- {
- for (int i = 1; i < 80 - 1; i++)
- {
- Mat[r][i] = ' ';
- }
- }
- for (int r = 1; r < 23; r++)
- {
- Mat[r][0] = 186;
- }
- Mat[0][0] = 201;
- }
- void Display(char Mat[][80])
- {
- system("cls");
- for (int r = 0; r < 24; r++)
- {
- for (int c = 0; c < 80; c++)
- {
- cout << Mat[r][c];
- }
- cout << endl;
- }
- cout.flush();
- Sleep(100);
- }
- void SetEnemy(char Mat[][80], int RE, int CE)
- {
- Mat[RE][CE] = 1;
- Mat[RE + 1][CE] = '|';
- Mat[RE + 2][CE] = '|';
- Mat[RE + 3][CE - 1] = '/';
- Mat[RE + 3][CE + 1] = '\\';
- }
- void SetHero(char Mat[][80], int RH, int CH)
- {
- Mat[RH][CH] = 2;
- Mat[RH + 1][CH] = 219;
- Mat[RH + 2][CH] = 219;
- }
- void MoveEnemy(int &RE, int &CE)
- {
- CE++;
- }
- void MoveHero(int &RH, int &CH, char k)
- {
- if (k == 'a')
- {
- CH--;
- }
- if (k == 'd')
- {
- CH++;
- }
- if (k == 'w')
- {
- RH--;
- }
- if (k == 's')
- {
- RH++;
- }
- }
- void main()
- {
- char Mat[24][80];
- int RE = 5;
- int CE = 12;
- int RH = 10;
- int CH = 20;
- while (true)
- {
- while (!_kbhit())
- {
- Design(Mat);
- MoveEnemy(RE, CE);
- SetEnemy(Mat, RE, CE);
- SetHero(Mat, RH, CH);
- Display(Mat);
- }
- Design(Mat);
- MoveEnemy(RE, CE);
- SetEnemy(Mat, RE, CE);
- char k = _getch();
- MoveHero(RH, CH, k);
- SetHero(Mat, RH, CH);
- Display(Mat);
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement