diff --git a/Header.cpp b/Header.cpp new file mode 100644 index 0000000..3582d94 --- /dev/null +++ b/Header.cpp @@ -0,0 +1,849 @@ +#include "Header.h" +#include +#include +#include +#include +#include + +using namespace sf; + + +int masbottom[3] = { 2, 3, 4 }; +int masright[3] = { 1, 3, 5 }; +int masleft[3] = { 0, 2, 6 }; +int masup[3] = { 0, 1, 7 }; +int counter = rand() % 1000; +int icounter = 0; + +int counterofall = 2; + +int countertriangle = 1; +int countersquare = 1; +int counterpentagon = 0; +const int radius = 35; +int delay = 0; + +using namespace sf; + + Point::Point(int x1, int y1) :x1(x1), y1(y1){}; + Point::Point() {}; + + + + Triangle::Triangle(int x1, int y1, int x2, int y2, int x3, int y3, int movex, int movey) : Point(x1, y1), x2(x2), x3(x3), y2(y2), y3(y3), movex(movex), movey(movey) { + centerx = (x3 - (y2 / 2)) / 2; + centery = y2 / 2; + hp = 0; + for (int i = 0; i < 3; ++i) { + color[i] = rand() % 255 + 1; + } + temp = 7; + }; + + Triangle::Triangle(const Triangle& triangle) { + this->x1 = triangle.x1; + this->y1 = triangle.y1; + this->x2 = triangle.x2; + this->x3 = triangle.x3; + this->y2 = triangle.y2; + this->y3 = triangle.y3; + this->centerx = triangle.centerx; + this->centery = triangle.centery; + this->hp = 0; + this->color[0] = triangle.color[0]; + this->color[1] = triangle.color[1]; + this->color[2] = triangle.color[2]; + this->movex = 600; + this->movey = 20; + this->temp = 4; + }; + + Triangle::Triangle() {} + + Triangle* Triangle::increasemas(Triangle mas[], int countertriangle, int exsisti) + { + Triangle newelement(mas[exsisti]); + Triangle* newmas = new Triangle[countertriangle]; + newmas[countertriangle - 1] = newelement; + for (int i = 0; i < countertriangle - 1; ++i) + { + newmas[i] = mas[i]; + } + delete[] mas; + return newmas; + } + + Triangle* Triangle::delmas(Triangle mas[], int& countertriangle) + { + bool dead = false; + for (int i = 0; i < countertriangle; ++i) + { + if (mas[i].hp == 3) + { + dead = true; + } + } + if (dead == true) + { + countertriangle--; + counterofall--; + Triangle* newmas = new Triangle[countertriangle]; + for (int i = 0, k = 0; i < countertriangle + 1; ++i) + { + if (mas[i].hp != 3) + { + newmas[k] = mas[i]; + k++; + } + } + delete[] mas; + return newmas; + } + } + + int Triangle::checkforexistence(Triangle mas[], int countertriangle) + { + for (int i = 0; i < countertriangle; ++i) + { + if (mas[i].hp != 3) + return i; + else + return 0; + } + } + + int Triangle::getterx1() { + return x1; + } + int Triangle::getterx2() { + return x2; + } + int Triangle::getterx3() { + return x3; + } + int Triangle::gettery1() { + return y1; + } + int Triangle::gettery2() { + return y2; + } + int Triangle::gettery3() { + return y3; + } + int Triangle::gettermovex() { + return movex; + } + int Triangle::gettermovey() { + return movey; + } + int Triangle::gettercolorR() { + return color[0]; + } + int Triangle::gettercolorG() { + return color[1]; + } + int Triangle::gettercolorB() { + return color[2]; + } + int Triangle::gettercenterx() { + return centerx; + } + int Triangle::gettercentery() { + return centery; + } + int Triangle::getterhp() { + return hp; + } + + void Triangle::setterhp(int hp) { + this->hp = hp; + } + + void Triangle::border() { + if (movey == 670) + { + temp = masbottom[rand() % 3]; + } + if (movex == 1280) + { + temp = masright[rand() % 3]; + } + if (movex == 10) + { + temp = masleft[rand() % 3]; + } + if (movey == 10) + { + temp = masup[rand() % 3]; + } + if (icounter == counter) + { + temp = rand() % 8; + counter = rand() % 1000; + icounter = 0; + } + ++icounter; + + } + + + void Triangle::move() { + // temp = rand() % 6; + if (temp == 0) + { + movex += 1; + movey += 1; + } + if (temp == 1) + { + movex -= 1; + movey += 1; + } + if (temp == 2) + { + movex += 1; + movey -= 1; + } + if (temp == 3) + { + movex -= 1; + movey -= 1; + } + if (temp == 4) + { + movex -= 0; + movey -= 1; + } + if (temp == 5) + { + movex -= 1; + movey -= 0; + } + if (temp == 6) + { + movex += 1; + movey -= 0; + } + if (temp == 7) + { + movex -= 0; + movey += 1; + } + } + + + + + Square::Square(int x1, int y1, int x2, int y2, int x3, int y3, int movex, int movey, int x4, int y4) :Triangle(x1, y1, x2, y2, x3, y3, movex, movey) { + centerx = x3 / 2; + centery = y2 / 2; + hp = 0; + for (int i = 0; i < 3; ++i) { + color[i] = rand() % 255 + 1; + } + this->x4 = x4; + this->y4 = y4; + } + + Square::Square() {}; + + Square::Square(const Square& square) { + this->x1 = square.x1; + this->y1 = square.y1; + this->x2 = square.x2; + this->x3 = square.x3; + this->x4 = square.x4; + this->y2 = square.y2; + this->y3 = square.y3; + this->y4 = square.y4; + this->centerx = square.centerx; + this->centery = square.centery; + this->hp = 0; + this->color[0] = square.color[0]; + this->color[1] = square.color[1]; + this->color[2] = square.color[2]; + this->movex = 600; + this->movey = 20; + this->temp = 4; + }; + + Square* Square::increasemas(Square mas[], int countertsquare, int exsisti) + { + Square newelement(mas[exsisti]); + Square* newmas = new Square[countertsquare]; + newmas[countertsquare - 1] = newelement; + for (int i = 0; i < countertsquare - 1; ++i) + { + newmas[i] = mas[i]; + } + delete[] mas; + return newmas; + } + + Square* Square::delmas(Square mas[], int& countertsquare) + { + bool dead = false; + for (int i = 0; i < countertsquare; ++i) + { + if (mas[i].hp == 3) + { + dead = true; + } + } + if (dead == true) + { + countertsquare--; + counterofall--; + Square* newmas = new Square[countertsquare]; + for (int i = 0, k = 0; i < countertsquare + 1; ++i) + { + if (mas[i].hp != 3) + { + newmas[k] = mas[i]; + k++; + } + } + delete[] mas; + return newmas; + } + } + + int Square::checkforexistence(Square mas[], int countertsquare) + { + for (int i = 0; i < countertsquare; ++i) + { + if (mas[i].hp != 3) + return i; + else + return 0; + } + } + + int Square::getterx4() { + return x4; + } + int Square::gettery4() { + return y4; + } + + + Pentagon::Pentagon(int x1, int y1, int x2, int y2, int x3, int y3, int movex, int movey, int x4, int y4, int x5, int y5) : Square(x1, y1, x2, y2, x3, y3, movex, movey, x4, y4) { + centerx = x4 / 2; + centery = y1; + hp = 0; + for (int i = 0; i < 3; ++i) { + color[i] = rand() % 255 + 1; + } + this->x5 = x5; + this->y5 = y5; + } + Pentagon::Pentagon() {} + + int Pentagon::getterx5() { + return x5; + } + int Pentagon::gettery5() { + return y5; + } + + Pentagon* Pentagon::increasemas(Pentagon mas[], int countertpentagon, int exsisti) + { + Pentagon newelement(mas[exsisti]); + Pentagon* newmas = new Pentagon[countertpentagon]; + newmas[countertpentagon - 1] = newelement; + for (int i = 0; i < countertpentagon - 1; ++i) + { + newmas[i] = mas[i]; + } + delete[] mas; + return newmas; + } + + int Pentagon::checkforexistence(Pentagon mas[], int counterpentagon) + { + for (int i = 0; i < counterpentagon; ++i) + { + if (mas[i].hp != 3) + return i; + else + return 0; + } + } + + Pentagon* Pentagon::delmas(Pentagon mas[], int& countertpentagon) + { + bool dead = false; + for (int i = 0; i < countertpentagon; ++i) + { + if (mas[i].hp == 3) + { + dead = true; + } + } + if (dead == true) + { + countertpentagon--; + counterofall--; + Pentagon* newmas = new Pentagon[countertpentagon]; + for (int i = 0, k = 0; i < countertpentagon + 1; ++i) + { + if (mas[i].hp != 3) + { + newmas[k] = mas[i]; + k++; + } + } + delete[] mas; + return newmas; + } + } + + void draw(RenderWindow& window, Triangle*& triangle, Square*& square, Pentagon*& pentagon, Sprite iHP[]) { + CircleShape circle[30]; + for (int i = 0; i < 30; ++i) { + circle[i].setRadius(radius); + } + + + for (int i = 0; i < countertriangle; ++i) { + + circle[i].setOrigin(radius, radius); + circle[i].setFillColor(Color(20, 60, 40, 240)); + circle[i].move(triangle[i].gettercenterx() + triangle[i].gettermovex(), triangle[i].gettercentery() + triangle[i].gettermovey()); + window.draw(circle[i]); + + ConvexShape triangle1; + + triangle1.setFillColor(Color(triangle[i].gettercolorR(), triangle[i].gettercolorG(), triangle[i].gettercolorB())); + + triangle1.setPointCount(3); + triangle1.setPoint(0, Vector2f(triangle[i].getterx1(), triangle[i].gettery1())); + triangle1.setPoint(1, Vector2f(triangle[i].getterx2(), triangle[i].gettery2())); + triangle1.setPoint(2, Vector2f(triangle[i].getterx3(), triangle[i].gettery3())); + triangle[i].border(); + triangle[i].move(); + triangle1.move(triangle[i].gettermovex(), triangle[i].gettermovey()); + iHP[triangle[i].getterhp()].setPosition(triangle[i].gettermovex() - 14, triangle[i].gettermovey() - 32); + + window.draw(iHP[triangle[i].getterhp()]); + window.draw(triangle1); + + + } + + for (int i = 0, j = 10; i < countersquare; ++i, ++j) { + + circle[j].setOrigin(radius, radius); + circle[j].setFillColor(Color(20, 60, 40, 240)); + circle[j].move(square[i].gettercenterx() + square[i].gettermovex(), square[i].gettercentery() + square[i].gettermovey()); + window.draw(circle[j]); + + ConvexShape square1; + + square1.setFillColor(Color(square[i].gettercolorR(), square[i].gettercolorG(), square[i].gettercolorB())); + + square1.setPointCount(4); + square1.setPoint(0, Vector2f(square[i].getterx1(), square[i].gettery1())); + square1.setPoint(1, Vector2f(square[i].getterx2(), square[i].gettery2())); + square1.setPoint(2, Vector2f(square[i].getterx3(), square[i].gettery3())); + square1.setPoint(3, Vector2f(square[i].getterx4(), square[i].gettery4())); + square[i].border(); + square[i].move(); + square1.move(square[i].gettermovex(), square[i].gettermovey()); + iHP[square[i].getterhp()].setPosition(square[i].gettermovex() - 14, square[i].gettermovey() - 32); + + window.draw(iHP[square[i].getterhp()]); + window.draw(square1); + + + + } + + + for (int i = 0, j = 20; i < counterpentagon; ++i, ++j) { + + circle[j].setOrigin(radius, radius); + + circle[j].setFillColor(Color(20, 60, 40, 240)); + circle[j].move(pentagon[i].gettercenterx() + pentagon[i].gettermovex(), pentagon[i].gettercentery() + pentagon[i].gettermovey()); + window.draw(circle[j]); + + ConvexShape pentagon1; + + pentagon1.setFillColor(Color(pentagon[i].gettercolorR(), pentagon[i].gettercolorG(), pentagon[i].gettercolorB())); + + pentagon1.setPointCount(5); + pentagon1.setPoint(0, Vector2f(pentagon[i].getterx1(), pentagon[i].gettery1())); + pentagon1.setPoint(1, Vector2f(pentagon[i].getterx2(), pentagon[i].gettery2())); + pentagon1.setPoint(2, Vector2f(pentagon[i].getterx3(), pentagon[i].gettery3())); + pentagon1.setPoint(3, Vector2f(pentagon[i].getterx4(), pentagon[i].gettery4())); + pentagon1.setPoint(4, Vector2f(pentagon[i].getterx5(), pentagon[i].gettery5())); + + pentagon[i].border(); + pentagon[i].move(); + pentagon1.move(pentagon[i].gettermovex(), pentagon[i].gettermovey()); + iHP[pentagon[i].getterhp()].setPosition(pentagon[i].gettermovex() - 5, pentagon[i].gettermovey() - 45); + + window.draw(iHP[pentagon[i].getterhp()]); + window.draw(pentagon1); + + } + + } + + int Objects(RenderWindow& window, Triangle*& triangle, Square*& square, Pentagon*& pentagon, Texture Cloud[], Texture Heart) { + int cloudcounter = 0; + if (check(window) == 0) + return 0; + if (countertriangle > 0 && countersquare > 0) + for (int newi = 0; newi < countertriangle; newi++) + { + for (int newj = 0; newj < countersquare; newj++) + { + if ((touch(triangle[newi], square[newj])) && (delay <= 0)) { + + if (rand() % 2) + { + Sprite iCloud[3]; + for (int i = 0; i < 3; i++) { + iCloud[i].setTexture(Cloud[i]); + iCloud[i].setPosition((square[newj].gettermovex() + triangle[newi].gettermovex()) / 2 - 15, (square[newj].gettermovey() + triangle[newi].gettermovey()) / 2 - 16); + } + + int countercloudtime = 0; + delay = 1000; + while (countercloudtime < 10) { + window.draw(iCloud[cloudcounter]); + cloudcounter++; + Sleep(100); + if (cloudcounter == 3) { + cloudcounter = 0; + } + countercloudtime++; + window.display(); + } + triangle[newi].setterhp(triangle[newi].getterhp() + 1); + square[newj].setterhp(square[newj].getterhp() + 1); + + if (triangle[newi].getterhp() == 3) + { + + triangle = triangle->delmas(triangle, countertriangle); + std::cout << countertriangle << countersquare << std::endl; + + + } + if (square[newj].getterhp() == 3) + { + square = square->delmas(square, countersquare); + int i = 100; + int j = 100; + + } + + + } + else + { + Sprite iHeart; + iHeart.setTexture(Heart); + int countercloudtime = 0; + delay = 1000; + while (countercloudtime < 10) { + + iHeart.setPosition((square[newj].gettermovex() + triangle[newi].gettermovex()) / 2 - 18 + rand() % 8, (square[newj].gettermovey() + triangle[newi].gettermovey()) / 2 - 19 + rand() % 8); + window.draw(iHeart); + Sleep(40); + + Sleep(100); + + countercloudtime++; + window.display(); + } + + if (rand() % 4 >= 1) + { + if (rand() % 2) + { + int exsisti = triangle->checkforexistence(triangle, countertriangle); + countertriangle++; + counterofall++; + triangle = triangle->increasemas(triangle, countertriangle, exsisti); + } + else + { + int exsisti = square->checkforexistence(square, countersquare); + countersquare++; + counterofall++; + square = square->increasemas(square, countersquare, exsisti); + } + } + else + { + int exsisti = pentagon->checkforexistence(pentagon, counterpentagon); + counterpentagon++; + counterofall++; + pentagon = pentagon->increasemas(pentagon, counterpentagon, exsisti); + } + + } + + + } + } + } + + if (check(window) == 0) + return 0; + if (countertriangle > 0 && counterpentagon > 0) + for (int newi = 0; newi < countertriangle; newi++) + { + for (int newj = 0; newj < counterpentagon; newj++) + { + if ((touch(triangle[newi], pentagon[newj])) && (delay <= 0)) { + if (rand() % 2) + { + Sprite iCloud[3]; + for (int i = 0; i < 3; i++) { + iCloud[i].setTexture(Cloud[i]); + iCloud[i].setPosition((pentagon[newj].gettermovex() + triangle[newi].gettermovex()) / 2 - 15, (pentagon[newj].gettermovey() + triangle[newi].gettermovey()) / 2 - 16); + } + + int countercloudtime = 0; + delay = 1000; + while (countercloudtime < 10) { + window.draw(iCloud[cloudcounter]); + cloudcounter++; + Sleep(100); + if (cloudcounter == 3) { + cloudcounter = 0; + } + countercloudtime++; + window.display(); + } + triangle[newi].setterhp(triangle[newi].getterhp() + 1); + pentagon[newj].setterhp(pentagon[newj].getterhp() + 1); + + if (triangle[newi].getterhp() == 3) + { + + triangle = triangle->delmas(triangle, countertriangle); + std::cout << countertriangle << counterpentagon << std::endl; + + + } + if (pentagon[newj].getterhp() == 3) + { + pentagon = pentagon->delmas(pentagon, counterpentagon); + int i = 100; + int j = 100; + + + } + + + } + else + { + Sprite iHeart; + iHeart.setTexture(Heart); + int countercloudtime = 0; + delay = 1000; + while (countercloudtime < 10) { + + iHeart.setPosition((pentagon[newj].gettermovex() + triangle[newi].gettermovex()) / 2 - 18 + rand() % 8, (pentagon[newj].gettermovey() + triangle[newi].gettermovey()) / 2 - 19 + rand() % 8); + window.draw(iHeart); + Sleep(40); + + Sleep(100); + + countercloudtime++; + window.display(); + } + if (rand() % 2) + { + int exsisti = triangle->checkforexistence(triangle, countertriangle); + countertriangle++; + counterofall++; + triangle = triangle->increasemas(triangle, countertriangle, exsisti); + } + else + { + int exsisti = pentagon->checkforexistence(pentagon, counterpentagon); + counterpentagon++; + counterofall++; + pentagon = pentagon->increasemas(pentagon, counterpentagon, exsisti); + } + + } + + + } + } + } + + if (check(window) == 0) + return 0; + if (counterpentagon > 0 && countersquare > 0) + for (int newi = 0; newi < counterpentagon; newi++) + { + for (int newj = 0; newj < countersquare; newj++) + { + if ((touch(square[newj], pentagon[newi])) && (delay <= 0)) { + if (rand() % 2) + { + Sprite iCloud[3]; + for (int i = 0; i < 3; i++) { + iCloud[i].setTexture(Cloud[i]); + iCloud[i].setPosition((square[newj].gettermovex() + pentagon[newi].gettermovex()) / 2 - 15, (square[newj].gettermovey() + pentagon[newi].gettermovey()) / 2 - 16); + } + + int countercloudtime = 0; + delay = 1000; + while (countercloudtime < 10) { + window.draw(iCloud[cloudcounter]); + cloudcounter++; + Sleep(100); + if (cloudcounter == 3) { + cloudcounter = 0; + } + countercloudtime++; + window.display(); + } + pentagon[newi].setterhp(pentagon[newi].getterhp() + 1); + square[newj].setterhp(square[newj].getterhp() + 1); + + if (pentagon[newi].getterhp() == 3) + { + + pentagon = pentagon->delmas(pentagon, counterpentagon); + std::cout << counterpentagon << countersquare << std::endl; + + + } + if (square[newj].getterhp() == 3) + { + square = square->delmas(square, countersquare); + int i = 100; + int j = 100; + + + } + + + } + else + { + Sprite iHeart; + iHeart.setTexture(Heart); + int countercloudtime = 0; + delay = 1000; + while (countercloudtime < 10) { + + iHeart.setPosition((square[newj].gettermovex() + pentagon[newi].gettermovex()) / 2 - 18 + rand() % 8, (square[newj].gettermovey() + pentagon[newi].gettermovey()) / 2 - 19 + rand() % 8); + window.draw(iHeart); + Sleep(40); + + Sleep(100); + + countercloudtime++; + window.display(); + } + if (rand() % 2) + { + int exsisti = pentagon->checkforexistence(pentagon, counterpentagon); + counterpentagon++; + counterofall++; + pentagon = pentagon->increasemas(pentagon, counterpentagon, exsisti); + } + else + { + int exsisti = square->checkforexistence(square, countersquare); + countersquare++; + counterofall++; + square = square->increasemas(square, countersquare, exsisti); + } + + } + + + } + } + } + } + + +int check(RenderWindow& window) { + + if (counterofall == 10) + { + Texture exit1; + exit1.loadFromFile("images/exit1.png"); + Sprite exxit1(exit1); + window.draw(exxit1); + window.display(); + Sleep(5000); + return 0; + } + + if (counterofall == 1 || counterofall == 0) + { + Texture exit3; + exit3.loadFromFile("images/exit3.png"); + Sprite exxit3(exit3); + window.draw(exxit3); + window.display(); + Sleep(5000); + return 0; + } + + if (counterpentagon == counterofall || countersquare == counterofall || countertriangle == counterofall) + { + Texture exit2; + exit2.loadFromFile("images/exit2.png"); + Sprite exxit2(exit2); + window.draw(exxit2); + window.display(); + Sleep(5000); + return 0; + } +} + +void menu(RenderWindow& window) { + Texture menuTexture1, menuTexture2, menuTexture3, aboutTexture, menuBackground; + menuTexture1.loadFromFile("images/start.png"); + menuTexture2.loadFromFile("images/exit.png"); + menuBackground.loadFromFile("images/fonmenu.png"); + Sprite menu1(menuTexture1), menu2(menuTexture2), menuBg(menuBackground); + bool isMenu = 1; + int menuNum = 0; + menu1.setPosition(535, 400); + menu2.setPosition(558, 500); + // menuBg.setPosition(0, 0); + + //////////////////////////////ÌÅÍÞ/////////////////// + while (isMenu) + { + menu1.setColor(Color::White); + menu2.setColor(Color::White); + menuNum = 0; + + + if (IntRect(535, 400, 230, 80).contains(Mouse::getPosition(window))) { menu1.setColor(Color::Red); menuNum = 1; } + if (IntRect(558, 500, 230, 80).contains(Mouse::getPosition(window))) { menu2.setColor(Color::Red); menuNum = 2; } + + if (Mouse::isButtonPressed(Mouse::Left)) + { + if (menuNum == 1) isMenu = false; + + if (menuNum == 2) { window.close(); isMenu = false; } + + } + + window.draw(menuBg); + + window.draw(menu1); + window.draw(menu2); + window.display(); + } +} \ No newline at end of file diff --git a/Header.h b/Header.h new file mode 100644 index 0000000..853fc7d --- /dev/null +++ b/Header.h @@ -0,0 +1,131 @@ +#include +#include +#include +#include +#include + +using namespace sf; + +extern int masbottom[3]; +extern int masright[3]; +extern int masleft[3]; +extern int masup[3]; +extern int counter; +extern int icounter; + +extern int counterofall; + +extern int countertriangle; +extern int countersquare; +extern int counterpentagon; +extern const int radius; +extern int delay; + +class Point +{ +public: + virtual int getterx1() = 0; + virtual int gettery1() = 0; + + Point(int x1, int y1); + Point(); +protected: + int x1; + int y1; +}; + +class Triangle : public Point { + +public: + Triangle(int x1, int y1, int x2, int y2, int x3, int y3, int movex, int movey); + Triangle(); + Triangle(const Triangle& triangle); + Triangle* increasemas(Triangle mas[], int countertriangle, int exsisti); + Triangle* delmas(Triangle mas[], int& countertriangle); + + int checkforexistence(Triangle mas[], int countertriangle); + virtual int getterx1(); + virtual int getterx2(); + virtual int getterx3(); + virtual int gettery1(); + virtual int gettery2(); + virtual int gettery3(); + virtual int gettermovex(); + virtual int gettermovey(); + virtual int gettercolorR(); + virtual int gettercolorG(); + virtual int gettercolorB(); + virtual int gettercenterx(); + virtual int gettercentery(); + virtual int getterhp(); + virtual void setterhp(int hp); + virtual void border(); + virtual void move(); +protected: + int x2; + int x3; + int y2; + int y3; + int centerx; + int centery; + int hp; + int color[3]; + int movex; + int movey; + int temp; + +}; + + + + +class Square : public Triangle { +public: + Square(int x1, int y1, int x2, int y2, int x3, int y3, int movex, int movey, int x4, int y4); + Square(); + Square(const Square& square); + + Square* increasemas(Square mas[], int countertsquare, int exsisti); + Square* delmas(Square mas[], int& countertsquare); + int checkforexistence(Square mas[], int countertsquare); + + virtual int getterx4(); + virtual int gettery4(); +protected: + int x4; + int y4; +}; + + + +class Pentagon : public Square { + +public: + Pentagon(int x1, int y1, int x2, int y2, int x3, int y3, int movex, int movey, int x4, int y4, int x5, int y5); + Pentagon(); + virtual int getterx5(); + virtual int gettery5(); + Pentagon* increasemas(Pentagon mas[], int countertpentagon, int exsisti); + Pentagon* delmas(Pentagon mas[], int& countertpentagon); + int checkforexistence(Pentagon mas[], int counterpentagon); +protected: + int x5; + int y5; +}; + +template +int touch(T& obj1, T1& obj2) { + unsigned int katet1, katet2; + katet1 = obj1.gettermovex() - obj2.gettermovex(); + katet2 = obj1.gettermovey() - obj2.gettermovey(); + if (sqrt(katet1 * katet1 + katet2 * katet2) <= (radius + radius)) + { + return 1; + } + else + return 0; +} +void draw(RenderWindow& window, Triangle*& triangle, Square*& square, Pentagon*& pentagon, Sprite iHP[]); +int Objects(RenderWindow& window, Triangle*& triangle, Square*& square, Pentagon*& pentagon, Texture Cloud[], Texture Heart); +int check(RenderWindow& window); +void menu(RenderWindow& window); \ No newline at end of file diff --git a/Images/HP2.png b/Images/HP2.png new file mode 100644 index 0000000..fe1b48c Binary files /dev/null and b/Images/HP2.png differ diff --git a/Images/HP3.png b/Images/HP3.png new file mode 100644 index 0000000..9c92257 Binary files /dev/null and b/Images/HP3.png differ diff --git a/Images/Heart.png b/Images/Heart.png new file mode 100644 index 0000000..b5c4c13 Binary files /dev/null and b/Images/Heart.png differ diff --git a/Images/birthportal1.png b/Images/birthportal1.png new file mode 100644 index 0000000..9e28bd6 Binary files /dev/null and b/Images/birthportal1.png differ diff --git a/Images/birthportal2.png b/Images/birthportal2.png new file mode 100644 index 0000000..e437166 Binary files /dev/null and b/Images/birthportal2.png differ diff --git a/Images/birthportal3.png b/Images/birthportal3.png new file mode 100644 index 0000000..18fbfbc Binary files /dev/null and b/Images/birthportal3.png differ diff --git a/Images/cloud.png b/Images/cloud.png new file mode 100644 index 0000000..3ed494e Binary files /dev/null and b/Images/cloud.png differ diff --git a/Images/cloud1.png b/Images/cloud1.png new file mode 100644 index 0000000..9d209e8 Binary files /dev/null and b/Images/cloud1.png differ diff --git a/Images/cloud2.png b/Images/cloud2.png new file mode 100644 index 0000000..544317d Binary files /dev/null and b/Images/cloud2.png differ diff --git a/Images/exit.png b/Images/exit.png new file mode 100644 index 0000000..3d9831c Binary files /dev/null and b/Images/exit.png differ diff --git a/Images/exit1.png b/Images/exit1.png new file mode 100644 index 0000000..5e0720c Binary files /dev/null and b/Images/exit1.png differ diff --git a/Images/exit2.png b/Images/exit2.png new file mode 100644 index 0000000..aed63e5 Binary files /dev/null and b/Images/exit2.png differ diff --git a/Images/exit3.png b/Images/exit3.png new file mode 100644 index 0000000..3ddb5df Binary files /dev/null and b/Images/exit3.png differ diff --git a/Images/exits.psd b/Images/exits.psd new file mode 100644 index 0000000..1ffd309 Binary files /dev/null and b/Images/exits.psd differ diff --git a/Images/fon.png b/Images/fon.png new file mode 100644 index 0000000..f2327cb Binary files /dev/null and b/Images/fon.png differ diff --git a/Images/fonforgame.png b/Images/fonforgame.png new file mode 100644 index 0000000..5fbd683 Binary files /dev/null and b/Images/fonforgame.png differ diff --git a/Images/fonforgame1.psd b/Images/fonforgame1.psd new file mode 100644 index 0000000..7173040 Binary files /dev/null and b/Images/fonforgame1.psd differ diff --git a/Images/fonmenu.png b/Images/fonmenu.png new file mode 100644 index 0000000..c54bc87 Binary files /dev/null and b/Images/fonmenu.png differ diff --git a/Images/heart, cloud.psd b/Images/heart, cloud.psd new file mode 100644 index 0000000..d053610 Binary files /dev/null and b/Images/heart, cloud.psd differ diff --git a/Images/hp1.png b/Images/hp1.png new file mode 100644 index 0000000..f8b9a4a Binary files /dev/null and b/Images/hp1.png differ diff --git a/Images/portal.psd b/Images/portal.psd new file mode 100644 index 0000000..8637aaf Binary files /dev/null and b/Images/portal.psd differ diff --git a/Images/start.png b/Images/start.png new file mode 100644 index 0000000..c9dd813 Binary files /dev/null and b/Images/start.png differ diff --git a/Images/startexit.psd b/Images/startexit.psd new file mode 100644 index 0000000..0cfb6c6 Binary files /dev/null and b/Images/startexit.psd differ diff --git a/Images/zast.psd b/Images/zast.psd new file mode 100644 index 0000000..b17d7ee Binary files /dev/null and b/Images/zast.psd differ diff --git "a/Images/\320\221\320\265\320\267 \320\270\320\274\320\265\320\275\320\270-3.psd" "b/Images/\320\221\320\265\320\267 \320\270\320\274\320\265\320\275\320\270-3.psd" new file mode 100644 index 0000000..63f42f6 Binary files /dev/null and "b/Images/\320\221\320\265\320\267 \320\270\320\274\320\265\320\275\320\270-3.psd" differ diff --git "a/Images/\320\221\320\265\320\267 \320\270\320\274\320\265\320\275\320\2701-1.psd" "b/Images/\320\221\320\265\320\267 \320\270\320\274\320\265\320\275\320\2701-1.psd" new file mode 100644 index 0000000..bdfbaa9 Binary files /dev/null and "b/Images/\320\221\320\265\320\267 \320\270\320\274\320\265\320\275\320\2701-1.psd" differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..a452774 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# КурÑÐ¾Ð²Ð°Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ð° / Course work + +## _По диÑциплине: «Объектно-ориентированное программирование»_ + +## _Тема: Â«Ð ÐµÐ°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð½ÐµÐºÐ¾Ñ‚Ð¾Ñ€Ð¾Ð³Ð¾ компьютерного мира»_ + +# + +### Технологии ООП, иÑпользованные в работе: + +- ИнкапÑулÑциÑ. +- ÐаÑледование: 4 клаÑÑа, один из которых абÑтрактный. +- Полиморфизм: иÑпользование конÑтрукторов, а так же их перегрузки. +- Виртуальные функции. +- МножеÑтвенное наÑледование (наÑледование 3-Ñ… клаÑÑов). +- КонÑтрукторы копированиÑ. +- Параметры по умолчанию. +- ИÑпользование объектов в качеÑтве аргументов или возвращаемых значений. diff --git a/Source.cpp b/Source.cpp new file mode 100644 index 0000000..1cf5ee9 --- /dev/null +++ b/Source.cpp @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include "Header.h" + +using namespace sf; + +int main() +{ + srand(time(0)); + Triangle* triangle = new Triangle[1] + { + {0, 0, 0, 20, 20, 10, 20, 20} + }; + + Square* square = new Square[1] + { + {0, 0, 0, 20, 20, 20, 300, 400, 20, 0} + }; + + Pentagon* pentagon = new Pentagon[1] + { + {0, 0, 12, 15, 27, 15, 400, 400, 39, 0, 20, -15} + }; + RenderWindow window(VideoMode(1300, 700), "LUDOJOP!"); + menu(window); + Clock clock; + //std::cout << triangle.gettercenterx() << " " << triangle.gettercentery() << std::endl; + //std::cout << square.gettercenterx() << " " << square.gettercentery() << std::endl; + + Texture Background; + Background.loadFromFile("Images/fonforgame.png"); + + Sprite iBackground; + iBackground.setTexture(Background); + + + Texture Portal[3]; + Portal[0].loadFromFile("Images/birthportal1.png"); + Portal[1].loadFromFile("Images/birthportal2.png"); + Portal[2].loadFromFile("Images/birthportal3.png"); + + Texture Heart; + Heart.loadFromFile("Images/Heart.png"); + + + Texture Cloud[3]; + Cloud[0].loadFromFile("Images/cloud.png"); + Cloud[1].loadFromFile("Images/cloud1.png"); + Cloud[2].loadFromFile("Images/cloud2.png"); + + Texture HP1; + HP1.loadFromFile("Images/HP1.png"); + + Texture HP2; + HP2.loadFromFile("Images/HP2.png"); + + Texture HP3; + HP3.loadFromFile("Images/HP3.png"); + + + + Sprite iHP[3]; + iHP[0].setTexture(HP1); + iHP[1].setTexture(HP2); + iHP[2].setTexture(HP3); + + int iforportal = 0; + int cloudcounter = 0; + int portalcounter = 0; + + + + while (window.isOpen()) + { + float time = clock.getElapsedTime().asMicroseconds(); + Event event; + while (window.pollEvent(event)) + { + if (event.type == Event::Closed) + window.close(); + } + + Sprite iPortal[3]; + if (portalcounter == 50) + { + portalcounter = 0; + iforportal++; + } + portalcounter++; + if (iforportal == 3) + { + iforportal = 0; + } + + iPortal[iforportal].setTexture(Portal[iforportal]); + iPortal[iforportal].setPosition(570, -22); + + + window.draw(iPortal[iforportal]); + draw(window, triangle, square, pentagon, iHP); + Objects(window, triangle, square, pentagon, Cloud, Heart); + delay--; + + window.display(); + window.draw(iBackground); + } + return 0; +} \ No newline at end of file