Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <ctime>
- #include <unordered_map>
- using namespace std;
- vector< vector<int> > map(0, vector<int>(0));
- int width;
- int height;
- class Point {
- int _x, _y;
- public:
- Point() {
- _x = 0;
- _y = 0;
- }
- Point(int x, int y) {
- _x = x;
- _y = y;
- }
- int getX() { return _x; }
- int getY() { return _y; }
- };
- // Отсюда вы можете брать цвета и здесь же создавать свои
- class ConsoleColor {
- public:
- static COLORREF red() { return RGB(255, 0, 0); }
- static COLORREF blue() { return RGB(0, 0, 255); }
- static COLORREF gray() { return RGB(200, 200, 200); }
- static COLORREF gray2() { return RGB(61, 58, 58); }
- static COLORREF white() { return RGB(255, 255, 255); }
- static COLORREF green() { return RGB(0, 255, 0); }
- static COLORREF black() { return RGB(0, 0, 0); }
- static COLORREF brown() { return RGB(80, 20, 25); }
- static COLORREF yellow() { return RGB(255, 255, 0); }
- static COLORREF purple() { return RGB(66, 49, 137); }
- static COLORREF redx() { return RGB(166, 15, 15); }
- };
- // Это класс, который нужен для рисования. В нем все готово. Ничего менять не нужно. Нужно только пользоваться
- class ConsoleDrawer {
- HANDLE _conHandle;
- HWND _hwnd;
- HDC _hdc;
- PAINTSTRUCT _ps;
- unordered_map<COLORREF, HGDIOBJ> _bm;
- unordered_map<COLORREF, HGDIOBJ> _pm;
- HGDIOBJ _curentBrush;
- HGDIOBJ _curentPen;
- int _width;
- int _height;
- bool _isWork = true;
- void selectBrush(COLORREF color, bool filled = false) {
- if (!filled) {
- SelectObject(_hdc, CreateSolidBrush(NULL_BRUSH));
- return;
- }
- if (_bm.find(color) == _bm.end())
- _bm.insert({ color, CreateSolidBrush(color) });
- if (_curentBrush != _bm[color]) {
- _curentBrush = _bm[color];
- SelectObject(_hdc, _curentBrush);
- }
- }
- void selectPen(COLORREF color) {
- if (_pm.find(color) == _pm.end())
- _pm.insert({ color, CreatePen(PS_SOLID, 1, color) });
- if (_curentPen != _pm[color]) {
- _curentPen = _pm[color];
- SelectObject(_hdc, _curentPen);
- }
- }
- public:
- ConsoleDrawer() {
- setlocale(LC_ALL, "");
- _conHandle = GetStdHandle(STD_INPUT_HANDLE);
- int t = sizeof(HGDIOBJ);
- _hwnd = GetConsoleWindow();
- RECT rc;
- GetClientRect(_hwnd, &rc);
- _width = rc.right;
- _height = rc.bottom;
- _hdc = GetDC(_hwnd);
- }
- void clearScreen() {
- system("cls");
- }
- int getWidth() { return _width; }
- int getHeight() { return _height; }
- HANDLE get_conHandle() {
- return _conHandle;
- }
- bool isWork() {
- return _isWork;
- }
- void stop() {
- _isWork = false;
- }
- void drawBackground(COLORREF color = ConsoleColor::gray()) {
- RECT rc;
- GetClientRect(_hwnd, &rc);
- drawRect(Point(), Point(_width, _height), color, true);
- }
- void drawPoint(Point p, COLORREF color) {
- SetPixel(_hdc, p.getX(), p.getY(), color);
- }
- void drawLine(Point p1, Point p2, COLORREF color) {
- selectPen(color);
- //SelectObject(_hdc, CreatePen(PS_SOLID, 1, color));
- //SetDCPenColor(_hdc, color);
- MoveToEx(_hdc, p1.getX(), p1.getY(), NULL);
- LineTo(_hdc, p2.getX(), p2.getY());
- }
- // Рисует круг или окружность по центру и радиусу
- // filled - нужно ли закрашивать внутренность
- void drawCircle(Point c, int radius, COLORREF color, bool filled = false) {
- selectPen(color);
- selectBrush(color, filled);
- //SetDCBrushColor(_hdc, color);
- Ellipse(_hdc, c.getX() - radius, c.getY() - radius, c.getX() + radius, c.getY() + radius);
- }
- // Рисует прямоугольник по двум точкам
- // p1 - нижний левый угол
- // p2 - верхний правый угол
- void drawRect(Point p1, Point p2, COLORREF color, bool filled = false) {
- selectPen(color);
- selectBrush(color, filled);
- Rectangle(_hdc, p1.getX(), p1.getY(), p2.getX(), p2.getY());
- }
- // Рисует треугольник по трем точкам
- void drawTriangle(Point p1, Point p2, Point p3, COLORREF color, bool filled = false) {
- selectPen(color);
- selectBrush(color, filled);
- POINT apt[3];
- apt[0].x = p1.getX(); apt[0].y = p1.getY();
- apt[1].x = p2.getX(); apt[1].y = p2.getY();
- apt[2].x = p3.getX(); apt[2].y = p3.getY();
- Polygon(_hdc, apt, 3);
- }
- };
- // Это самый базовый класс, от которого наследуются все объекты, которые появляются на поле
- class ParkObject {
- protected:
- int _cellX, _cellY, _cellSize, _score;
- public:
- ParkObject(int cellX, int cellY, int cellSize) {
- _cellX = cellX;
- _cellY = cellY;
- _cellSize = cellSize;
- }
- bool isInside(int cellX, int cellY) {
- return (_cellX == cellX) && (_cellY == cellY);
- }
- int getCellX() {
- return _cellX;
- }
- int getCellY() {
- return _cellY;
- }
- int getX() {
- return _cellX * _cellSize;
- }
- int getY() {
- return _cellY * _cellSize;
- }
- };
- class Obstacle : public ParkObject {
- public:
- Obstacle(int cellX, int cellY, int cellSize) : ParkObject(cellX, cellY, cellSize) { }
- };
- class Lake :public Obstacle {
- public:
- Lake(int cellX, int cellY, int cellSize) : Obstacle(cellX, cellY, cellSize) {}
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- double d = _cellSize / 100.0;
- cd.drawRect(Point(x, y), Point(x + _cellSize, y + _cellSize), ConsoleColor::blue(), true);
- }
- };
- class block :public Obstacle {
- public:
- block(int cellX, int cellY, int cellSize) : Obstacle(cellX, cellY, cellSize) {}
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- double d = _cellSize / 100.0;
- cd.drawRect(Point(x, y), Point(x + _cellSize, y + _cellSize), ConsoleColor::gray2(), true);
- }
- };
- class SnowMan : public Obstacle {
- public:
- SnowMan(int cellX, int cellY, int cellSize) : Obstacle(cellX, cellY, cellSize) { }
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- double d = _cellSize / 100.0;
- cd.drawCircle(Point(x + _cellSize / 2, y + _cellSize - 20 * d), 20 * d, ConsoleColor::white(), true);
- cd.drawCircle(Point(x + _cellSize / 2, y + _cellSize - 55 * d), 15 * d, ConsoleColor::white(), true);
- cd.drawCircle(Point(x + _cellSize / 2, y + _cellSize - 80 * d), 10 * d, ConsoleColor::white(), true);
- cd.drawRect(Point(x + _cellSize / 2 - 5 * d, y + 10 * d), Point(x + _cellSize / 2 + 5 * d, y + d), ConsoleColor::brown(), true);
- }
- };
- class Tree : public ParkObject {
- public:
- Tree(int cellX, int cellY, int cellSize) : ParkObject(cellX, cellY, cellSize) {}
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- int d = _cellSize / 10;
- cd.drawRect(Point(x + 4 * d, y + _cellSize), Point(x + 6 * d, y + _cellSize - 2 * d), ConsoleColor::brown(), true);
- cd.drawTriangle(Point(x + 2 * d, y + _cellSize - 2 * d), Point(x + _cellSize / 2, y + d), Point(x + _cellSize - 2 * d, y + _cellSize - 2 * d), ConsoleColor::green(), true);
- }
- };
- class HappyDino : public ParkObject {
- public:
- HappyDino(int cellX, int cellY, int cellSize) : ParkObject(cellX, cellY, cellSize) {}
- COLORREF color = ConsoleColor::green();
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- double d = _cellSize / 125.0;
- cd.drawRect(Point(x + d, y + 63 * d), Point(x + 24 * d, y + 53 * d), color, true);
- cd.drawRect(Point(x + 75 * d, y + 63 * d), Point(x + 98 * d, y + 53 * d), color, true);
- cd.drawRect(Point(x + 27 * d, y + 93 * d), Point(x + 72 * d, y + 35 * d), color, true);//body
- cd.drawRect(Point(x + 27 * d, y + 124 * d), Point(x + 42 * d, y + 94 * d), color, true);
- cd.drawRect(Point(x + 57 * d, y + 124 * d), Point(x + 72 * d, y + 94 * d), color, true);
- cd.drawRect(Point(x + 27 * d, y + 32 * d), Point(x + 88 * d, y + 2 * d), color, true);//head
- cd.drawCircle(Point(x + 42 * d, y + 12 * d), 8 * d, ConsoleColor::gray(), true);
- cd.drawTriangle(Point(x + 27 * d, y), Point(x + 49 * d, y - 45 * d), Point(x + 72 * d, y), ConsoleColor::red(), true);
- cd.drawCircle(Point(x + 49 * d, y - 50 * d), 10 * d, ConsoleColor::white(), true);
- }
- void step(int direction) {
- if (direction == 0)
- _cellX -= 1;
- if (direction == 1)
- _cellY -= 1;
- if (direction == 2)
- _cellX += 1;
- if (direction == 3)
- _cellY += 1;
- }
- };
- //HappyDino2
- /*class HappyDino2 : public ParkObject {
- public:
- HappyDino2(int cellX, int cellY, int cellSize) : ParkObject(cellX, cellY, cellSize) {}
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- COLORREF color = ConsoleColor::green();
- double d = _cellSize / 125.0;
- cd.drawRect(Point(x + d, y + 63 * d), Point(x + 24 * d, y + 53 * d), ConsoleColor::purple(), true);
- cd.drawRect(Point(x + 75 * d, y + 63 * d), Point(x + 98 * d, y + 53 * d), ConsoleColor::purple(), true);
- cd.drawRect(Point(x + 27 * d, y + 93 * d), Point(x + 72 * d, y + 35 * d), ConsoleColor::purple(), true);//body
- cd.drawRect(Point(x + 27 * d, y + 124 * d), Point(x + 42 * d, y + 94 * d), ConsoleColor::purple(), true);
- cd.drawRect(Point(x + 57 * d, y + 124 * d), Point(x + 72 * d, y + 94 * d), ConsoleColor::purple(), true);
- cd.drawRect(Point(x + 27 * d, y + 32 * d), Point(x + 88 * d, y + 2 * d), ConsoleColor::purple(), true);//head
- cd.drawCircle(Point(x + 42 * d, y + 12 * d), 8 * d, ConsoleColor::gray(), true);
- cd.drawTriangle(Point(x + 27 * d, y), Point(x + 49 * d, y - 45 * d), Point(x + 72 * d, y), ConsoleColor::red(), true);
- cd.drawCircle(Point(x + 49 * d, y - 50 * d), 10 * d, ConsoleColor::white(), true);
- }
- void step(int direction) {
- if (direction == 0)
- _cellX -= 1;
- if (direction == 1)
- _cellY -= 1;
- if (direction == 2)
- _cellX += 1;
- if (direction == 3)
- _cellY += 1;
- }
- };
- */
- //AngryDino
- class AngryDino : public ParkObject {
- public:
- AngryDino(int cellX, int cellY, int cellSize) : ParkObject(cellX, cellY, cellSize) {}
- void draw(ConsoleDrawer& cd) {
- //Переходим от ячеек к координатам пикселей
- int x = getX();
- int y = getY();
- COLORREF color = ConsoleColor::redx();
- vector<vector <int> > matrix(width, vector<int>(height));
- double d = _cellSize / 125.0;
- cd.drawRect(Point(x + d, y + 63 * d), Point(x + 24 * d, y + 53 * d), ConsoleColor::redx(), true);
- cd.drawRect(Point(x + 75 * d, y + 63 * d), Point(x + 98 * d, y + 53 * d), ConsoleColor::redx(), true);
- cd.drawRect(Point(x + 27 * d, y + 93 * d), Point(x + 72 * d, y + 35 * d), ConsoleColor::redx(), true);//body
- cd.drawRect(Point(x + 27 * d, y + 124 * d), Point(x + 42 * d, y + 94 * d), ConsoleColor::redx(), true);
- cd.drawRect(Point(x + 57 * d, y + 124 * d), Point(x + 72 * d, y + 94 * d), ConsoleColor::redx(), true);
- cd.drawRect(Point(x + 27 * d, y + 32 * d), Point(x + 88 * d, y + 2 * d), ConsoleColor::redx(), true);//head
- cd.drawCircle(Point(x + 42 * d, y + 12 * d), 8 * d, ConsoleColor::gray(), true);
- cd.drawTriangle(Point(x + 27 * d, y), Point(x + 49 * d, y - 45 * d), Point(x + 72 * d, y), ConsoleColor::red(), true);
- cd.drawCircle(Point(x + 49 * d, y - 50 * d), 10 * d, ConsoleColor::white(), true);
- }
- void step(int direction) {
- if (direction == 0)
- _cellX -= 1;
- if (direction == 1)
- _cellY -= 1;
- if (direction == 2)
- _cellX += 1;
- if (direction == 3)
- _cellY += 1;
- }
- };
- class DinoPark {
- int score1, score2;
- int hp1 = 3, hp2 = 3;
- int _cellsXCount;
- int _cellsYCount;
- int _cellSize;
- vector<Lake> _lake;
- vector<block> _block;
- vector<Obstacle> _obstacle;
- vector<SnowMan> _snowmen;
- vector<Tree> _trees;
- vector<HappyDino> _hDino;
- //vector<HappyDino2> _hDino2;
- vector<AngryDino> _hDino3;
- public:
- DinoPark(int width, int height, int cellSize) {
- _cellsXCount = width;
- _cellsYCount = height;
- _cellSize = cellSize;
- }
- void setdinocolor(int num, COLORREF color) {
- _hDino[num].color = color;
- }
- // Этот метод проверяет, что находится в клетке:
- // -1 - снеговик ,озеро ,блок
- // 0 - пусто
- // 1 - дерево
- // 2 - динозавр
- // 3 - динозавр
- // 4 - Злой динозавр
- int find(int x, int y) {
- for (int i = 0; i < _obstacle.size(); i++) {
- if (_obstacle[i].isInside(x, y))
- return -1;
- }
- for (int i = 0; i < _trees.size(); i++) {
- if (_trees[i].isInside(x, y))
- return 1;
- }
- for (int i = 0; i < _hDino.size(); i++) {
- if (_hDino[i].isInside(x, y))
- return 2;
- }
- // for (int i = 0; i < _hDino2.size(); i++) {
- // if (_hDino2[i].isInside(x, y))
- // return 2;
- // }
- for (int i = 0; i < _hDino3.size(); i++) {
- if (_hDino3[i].isInside(x, y))
- return 4;
- }
- return 0;
- }
- // Метод для отрисовки всего поля
- void draw(ConsoleDrawer& cd) {
- // Рисуем сетку
- for (int i = 0; i <= _cellsXCount; i++) {
- int x = i * _cellSize;
- int y = _cellsYCount * _cellSize;
- cd.drawLine(Point(x, 0), Point(x, y), ConsoleColor::black());
- }
- for (int i = 0; i <= _cellsYCount; i++) {
- int x = _cellsXCount * _cellSize;
- int y = i * _cellSize;
- cd.drawLine(Point(0, y), Point(x, y), ConsoleColor::black());
- }
- // Рисуем снеговиков
- for (int i = 0; i < _snowmen.size(); i++) {
- _snowmen[i].draw(cd);
- }
- // Рисуем деревья
- for (int i = 0; i < _trees.size(); i++) {
- _trees[i].draw(cd);
- }
- // Рисуем динозавра
- for (int i = 0; i < _hDino.size(); i++) {
- _hDino[i].draw(cd);
- }
- // // Рисуем динозавра2
- // for (int i = 0; i < _hDino2.size(); i++) {
- // _hDino2[i].draw(cd);
- // }
- // Рисуем ЗлогоДинозавра
- for (int i = 0; i < _hDino3.size(); i++) {
- _hDino3[i].draw(cd);
- }
- for (int i = 0; i < _lake.size(); i++) {
- _lake[i].draw(cd);
- }
- for (int i = 0; i < _block.size(); i++) {
- _block[i].draw(cd);
- }
- }
- // Метод обработки вашего хода
- void step(ConsoleDrawer& cd) {
- // Пока ходит только счастливый динозавр
- // Ловим нажатие на клавиатуру
- KEY_EVENT_RECORD key;
- INPUT_RECORD irec[100];
- DWORD cc;
- ReadConsoleInput(cd.get_conHandle(), irec, 100, &cc);
- for (DWORD j = 0; j < cc; ++j) {
- if (irec[j].EventType == KEY_EVENT && irec[j].Event.KeyEvent.bKeyDown) {
- for (int i = 0; i < _hDino.size(); i++) {
- // Смотрим по сторонам
- // -1 - снеговик
- // 0 - пусто
- // 1 - дерево
- // 2 - динозавр
- vector<int> res = {
- lookLeft(_hDino[i].getCellX(),_hDino[i].getCellY()),
- lookUp(_hDino[i].getCellX(), _hDino[i].getCellY()),
- lookRight(_hDino[i].getCellX(), _hDino[i].getCellY()),
- lookDown(_hDino[i].getCellX(), _hDino[i].getCellY())
- // lookLeft(_hDino2[i].getCellX(),_hDino2[i].getCellY()),
- // lookUp(_hDino2[i].getCellX(), _hDino2[i].getCellY()),
- // lookRight(_hDino2[i].getCellX(), _hDino2[i].getCellY()),
- // lookDown(_hDino2[i].getCellX(), _hDino2[i].getCellY())
- };
- // Проверяем, какая именно кнопка была нажата
- switch (irec[j].Event.KeyEvent.wVirtualKeyCode) {
- case VK_LEFT:
- if (i == 0)
- if (res[0] == 1 || res[0] == 0) {
- if (res[0] == 1)
- score1++;
- _hDino[0].step(0);
- if (res[0] != 0) {
- refresh(cd);
- }
- }
- break;
- case VK_UP:
- if (i == 0)
- if (res[1] == 1 || res[1] == 0) {
- _hDino[0].step(1);
- if (res[1] != 0) {
- refresh(cd);
- }
- }
- break;
- case VK_RIGHT:
- if (i == 0)
- if (res[2] == 1 || res[2] == 0) {
- _hDino[0].step(2);
- if (res[2] != 0) {
- refresh(cd);
- }
- }
- break;
- case VK_DOWN:
- if (i == 0)
- if (res[3] == 1 || res[3] == 0) {
- _hDino[0].step(3);
- if (res[3] != 0) {
- refresh(cd);
- }
- }
- break;
- //Dino2
- case 0x57://W
- if (i == 1)
- if (res[1] == 1 || res[1] == 0) {
- _hDino[1].step(1);
- if (res[1] != 0) {
- refresh(cd);
- }
- }
- break;
- case 0x41://A
- if (i == 1)
- if (res[0] == 1 || res[0] == 0) {
- _hDino[1].step(0);
- if (res[0] != 0) {
- refresh(cd);
- }
- }
- break;
- case 0x44://D
- if (i == 1)
- if (res[2] == 1 || res[2] == 0) {
- _hDino[1].step(2);
- if (res[2] != 0) {
- refresh(cd);
- }
- }
- break;
- case 0x53://S
- if (i == 1)
- if (res[3] == 1 || res[3] == 0) {
- _hDino[1].step(3);
- if (res[3] != 0) {
- refresh(cd);
- }
- }
- break;
- case VK_ESCAPE:
- if (i == 0) {
- cd.clearScreen();
- cout << "Score player 1: " << score1 << endl;
- cout << "HP player 1: " << hp1 << endl;
- cout << "Score player 2: " << score2 << endl;
- cout << "HP player 2: " << hp2 << endl;
- cd.stop();
- break;
- }
- }
- }
- }
- }
- }
- void addSnowMan(int x, int y) {
- _obstacle.push_back(Obstacle(x, y, _cellSize));
- _snowmen.push_back(SnowMan(x, y, _cellSize));
- map[x][y] = -1;
- }
- void addTree(int x, int y) {
- _trees.push_back(Tree(x, y, _cellSize));
- map[x][y] = 1;
- }
- void addHappyDino(int x, int y) {
- _hDino.push_back(HappyDino(x, y, _cellSize));
- map[x][y] = 2;
- }
- //void addHappyDino2(int x, int y) {
- // _hDino2.push_back(HappyDino2(x, y, _cellSize));
- //}
- void addAngryDino(int x, int y) {
- _hDino3.push_back(AngryDino(x, y, _cellSize));
- map[x][y] = -2;
- }
- void addLake(int x, int y) {
- _obstacle.push_back(Obstacle(x, y, _cellSize));
- _lake.push_back(Lake(x, y, _cellSize));
- map[x][y] = -1;
- }
- void addBlock(int x, int y) {
- _obstacle.push_back(Obstacle(x, y, _cellSize));
- _block.push_back(block(x, y, _cellSize));
- map[x][y] = -1;
- }
- // Взгляд на клетку вверх
- int lookUp(int cellX, int cellY) {
- if (cellY == 0)
- return -1;
- return find(cellX, cellY - 1);
- }
- // Взгляд на клетку вниз
- int lookDown(int cellX, int cellY) {
- if (cellY == _cellsYCount - 1)
- return -1;
- return find(cellX, cellY + 1);
- }
- // Взгляд на клетку вправо
- int lookRight(int cellX, int cellY) {
- if (cellX == _cellsXCount - 1)
- return -1;
- return find(cellX + 1, cellY);
- }
- // Взгляд на клетку влево
- int lookLeft(int cellX, int cellY) {
- if (cellX == 0)
- return -1;
- return find(cellX - 1, cellY);
- }
- // Обновляем картину
- void refresh(ConsoleDrawer& cd) {
- for (int i = 0; i < _hDino.size(); i++) {
- // Смотрим, где стоит динозавр
- int x = _hDino[i].getCellX();
- int y = _hDino[i].getCellY();
- for (int i = 0; i < _hDino3.size(); i++) {
- int x1 = _hDino3[i].getCellX();
- int y2 = _hDino3[i].getCellY();
- if (x1 == x && y2 == y)
- cd.stop();
- //cout << " YOU DIED" << endl;
- //cout << "score player 1 : " << score1 << endl;
- //cout << "score player 2 : " << score2 << endl;
- }
- // Находим то дерево, на котором он стоит
- for (int j = 0; j < _trees.size(); j++) {
- if (_trees[j].isInside(x, y)) {
- //СЧЕТ елочек СЧЕТ елочек
- score1 = score1 + 1;
- // hp = hp + 1;
- //cout << score;
- // Переносим дерево в другое место
- // Цикл нужен, чтобы не попасть в место, которое уже занято
- for (int k = 0; k < 100; k++) {
- int _x = rand() % _cellsXCount;
- int _y = rand() % _cellsYCount;
- if (find(_x, _y) == 0) {
- _trees[j] = Tree(_x, _y, _cellSize);
- break;
- }
- }
- }
- }
- }
- }
- };
- int main() {
- ConsoleDrawer cd;
- srand(time(0));
- const int CellSize = 20; //РАЗМЕР
- width = cd.getWidth() / CellSize;
- height = cd.getHeight() / CellSize;
- DinoPark dinoPark(width, height, CellSize);
- for (int i = 0; i < width; i++) {
- map.push_back(vector<int>(0));
- for (int j = 0; j < height; j++)
- map[i].push_back(0);
- }
- for (int i = 0; i < width; i++) {
- dinoPark.addBlock(i, 0);
- dinoPark.addBlock(i, height - 1);
- }
- for (int i = 1; i < height; i++) {
- dinoPark.addBlock(width - 1, i);
- dinoPark.addBlock(0, i);
- }
- dinoPark.addSnowMan(5, 3);
- dinoPark.addSnowMan(5, 9);
- dinoPark.addSnowMan(10, 4);
- for (int i = 1; i < width - 1; i++) {
- dinoPark.addTree(i, 1);
- }
- dinoPark.addLake(7, 5);
- dinoPark.addLake(8, 5);
- dinoPark.addLake(9, 5);
- dinoPark.addLake(6, 5);
- dinoPark.addLake(7, 6);
- dinoPark.addLake(8, 6);
- dinoPark.addLake(9, 6);
- dinoPark.addLake(7, 7);
- dinoPark.addLake(8, 7);
- dinoPark.addLake(9, 7);
- dinoPark.addLake(10, 7);
- dinoPark.addHappyDino(1, 4);
- dinoPark.addHappyDino(1, 2);
- dinoPark.setdinocolor(1, ConsoleColor::purple());
- dinoPark.addAngryDino(22, 6);
- cd.clearScreen();
- while (cd.isWork()) {
- cd.drawBackground();
- dinoPark.draw(cd);
- dinoPark.step(cd);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement