diff --git a/sem2/Boyarova/DinoGame3000/DinoGame3000.exe b/sem2/Boyarova/DinoGame3000/DinoGame3000.exe new file mode 100644 index 00000000..debcf1ff Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/DinoGame3000.exe differ diff --git a/sem2/Boyarova/DinoGame3000/DinoGame3000.sln b/sem2/Boyarova/DinoGame3000/DinoGame3000.sln new file mode 100644 index 00000000..1ba76203 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/DinoGame3000.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34928.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DinoGame3000", "DinoGame3000.vcxproj", "{030DC2CE-9B2A-4644-AC20-41A9B4E874A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Debug|x64.ActiveCfg = Debug|x64 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Debug|x64.Build.0 = Debug|x64 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Debug|x86.ActiveCfg = Debug|Win32 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Debug|x86.Build.0 = Debug|Win32 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Release|x64.ActiveCfg = Release|x64 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Release|x64.Build.0 = Release|x64 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Release|x86.ActiveCfg = Release|Win32 + {030DC2CE-9B2A-4644-AC20-41A9B4E874A2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {44177892-565E-4EC6-BA6B-258FE3125A70} + EndGlobalSection +EndGlobal diff --git a/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj b/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj new file mode 100644 index 00000000..5da3a0b7 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj @@ -0,0 +1,172 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 17.0 + Win32Proj + {030dc2ce-9b2a-4644-ac20-41a9b4e874a2} + DinoGame3000 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\KK\source\SFML-2.6.1-windows-vc17-64-bit\SFML-2.6.1\include;%(AdditionalIncludeDirectories) + + + Windows + true + C:\Users\KK\source\SFML-2.6.1-windows-vc17-64-bit\SFML-2.6.1\lib;%(AdditionalLibraryDirectories) + sfml-graphics-d.lib;sfml-window-d.lib;sfml-audio-d.lib;sfml-system-d.lib;%(AdditionalDependencies) + mainCRTStartup + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj.filters b/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj.filters new file mode 100644 index 00000000..fb3b5304 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj.filters @@ -0,0 +1,91 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + + + + + + + + + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj.user b/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/DinoGame3000.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/End.cpp b/sem2/Boyarova/DinoGame3000/End.cpp new file mode 100644 index 00000000..83976a34 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/End.cpp @@ -0,0 +1,131 @@ +#pragma once +#include "End.h" +#include "Help.h" +#include "GameMenu.h" +#include + +void Victory(sf::RenderWindow& window) +{ + sf::Font MC; + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(1000, 620); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(990, 610); + + sf::Text Fail(L"", MC, 80); + Fail.setFillColor(sf::Color::Green); + Fail.setOutlineThickness(5); + Fail.setOutlineColor(sf::Color(150, 0, 3)); + Fail.setPosition(280, 290); + + + bool isMouseOver = false; + sf::Vector2i pixelPos = sf::Mouse::getPosition(window); + sf::Event event; + while (window.pollEvent(event)) + { + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + else if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = false; + } + + } + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 1; + } + + } + if (event.type == sf::Event::Closed) + window.close(); + window.display(); + } + + window.clear(sf::Color::Black); + window.draw(Exit); + window.draw(Fail); + window.draw(exitButton); +} + + +void Fail(sf::RenderWindow& window) +{ + sf::Font MC; + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(1000, 620); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(990, 610); + + sf::Text Fail(L"", MC, 80); + Fail.setFillColor(sf::Color::Red); + Fail.setOutlineThickness(5); + Fail.setOutlineColor(sf::Color(150, 0, 3)); + Fail.setPosition(280, 290); + + + bool isMouseOver = false; + sf::Vector2i pixelPos = sf::Mouse::getPosition(window); + sf::Event event; + while (window.pollEvent(event)) + { + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + else if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = false; + } + + } + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 1; + } + + } + if (event.type == sf::Event::Closed) + window.close(); + window.display(); + } + + window.clear(sf::Color::Black); + window.draw(Exit); + window.draw(Fail); + window.draw(exitButton); + +} \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/End.h b/sem2/Boyarova/DinoGame3000/End.h new file mode 100644 index 00000000..e194da19 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/End.h @@ -0,0 +1,5 @@ +#pragma once +#include + +void Victory(sf::RenderWindow& window); +void Fail(sf::RenderWindow& window); diff --git a/sem2/Boyarova/DinoGame3000/Fun.cpp b/sem2/Boyarova/DinoGame3000/Fun.cpp new file mode 100644 index 00000000..f9ed8873 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Fun.cpp @@ -0,0 +1,393 @@ +#include "Help.h" +#include "Player.h" +#include "Fun.h" +#include +#include +#include "windows.h" + +using namespace sf; + +class Dino +{ +protected: + int STR; + int DEX; + int INT; + int hp = 100; + Terrain Ter; + std::string Name; + +public: + virtual int damage(Terrain terrain) = 0; + void set_strength(int st) { STR = st; } + void set_agility(int de) { DEX = de; } + void set_brain(int in) { INT = in; } + void setHealth(int); + void setHealth2(int); + int getHealth() { return hp; } +}; + +class PlainDino : protected Dino { +public: + PlainDino(); + PlainDino(int str, int dex, int intel, Terrain terrain, std::string N) { + STR = str; + DEX = dex; + INT = intel; + hp = 100; + Ter = terrain; + Name = N; + }; + PlainDino(const PlainDino& other) = default; + PlainDino& operator=(const PlainDino& other) = default; + int damage(Terrain terrain) { + if (terrain == Terrain::Plain) + return (2 * STR); + else if (terrain == Terrain::River) + return DEX; + return INT; + }; + int getHealth() { return hp; } +}; + +class RiverDino : protected Dino { +public: + RiverDino(); + RiverDino(int str, int dex, int intel, Terrain terrain, std::string N) { + STR = str; + DEX = dex; + INT = intel; + hp = 100; + Ter = terrain; + Name = N; + }; + RiverDino(const RiverDino& other) = default; + RiverDino& operator=(const RiverDino& other) = default; + int damage(Terrain terrain) { + if (terrain == Terrain::Plain) + return STR; + else if (terrain == Terrain::River) + return (2 * DEX); + return INT; + } + int getHealth() { return hp; } +}; + +class MountainDino : protected Dino { +public: + MountainDino(); + MountainDino(int str, int dex, int intel, Terrain terrain, std::string N) { + STR = str; + DEX = dex; + INT = intel; + hp = 100; + Ter = terrain; + Name = N; + }; + MountainDino(const MountainDino& other) = default; + MountainDino& operator=(const MountainDino& other) = default; + int damage(Terrain terrain) { + + if (terrain == Terrain::Plain) + return STR; + else if (terrain == Terrain::River) + return DEX; + else if (terrain == Terrain::Mountain) + return (2 * INT); + } + int getHealth() { return hp; } +}; + +#include + +void Fun(int A, int B, int C, sf::RenderWindow& window) { + + PlainDino DCyno(33, 22, 11, Terrain::Plain, "Syno"); + RiverDino DNari(11, 33, 22, Terrain::River, "Nari"); + RiverDino DKaveh(22, 22, 22, Terrain::River, "Kaveh"); + MountainDino DHaitam(22, 11, 33, Terrain::Mountain, "Haitam"); + extern Terrain TPlay; + if (C == 0) { + Terrain TPlay = Terrain::Plain; + } + if (C == 1) { + Terrain TPlay = Terrain::River; + } + if (C == 2) { + Terrain TPlay = Terrain::Mountain; + } + + Player player2; + player2.LoadGame("data.txt"); + int DMy, D2; + int HMy, H2; + Texture Dino1, Dino2, Dino3, Dino4; + Dino1.loadFromFile("images/DCyno.jpg"); + Dino2.loadFromFile("images/DNari.jpg"); + Dino3.loadFromFile("images/DKaveh.jpg"); + Dino4.loadFromFile("images/DHaitam.jpg"); + Sprite Sprite1, Sprite2, Sprite3, Sprite4, Sprite12, Sprite22, Sprite32, Sprite42; + if (A == 1) { + Sprite1.setTexture(Dino1); + Sprite1.setPosition(180, 200); + DMy = DCyno.damage(TPlay); + HMy = DCyno.getHealth(); + } + if (A == 2) { + Sprite2.setTexture(Dino2); + Sprite2.setPosition(180, 200); + DMy = DNari.damage(TPlay); + HMy = DNari.getHealth(); + } + if (A == 3) { + Sprite3.setTexture(Dino3); + Sprite3.setPosition(180, 200); + DMy = DKaveh.damage(TPlay); + HMy = DKaveh.getHealth(); + } + if (A == 4) { + Sprite4.setTexture(Dino4); + Sprite4.setPosition(180, 200); + DMy = DHaitam.damage(TPlay); + HMy = DHaitam.getHealth(); + } + + if (B == 0) { + Sprite12.setTexture(Dino1); + Sprite12.setPosition(900, 200); + D2 = DCyno.damage(TPlay); + H2 = DCyno.getHealth(); + } + if (B == 1) { + Sprite22.setTexture(Dino2); + Sprite22.setPosition(900, 200); + D2 = DNari.damage(TPlay); + H2 = DNari.getHealth(); + } + if (B == 2) { + Sprite32.setTexture(Dino3); + Sprite32.setPosition(900, 200); + D2 = DKaveh.damage(TPlay); + H2 = DKaveh.getHealth(); + } + if (B == 3) { + Sprite42.setTexture(Dino4); + Sprite42.setPosition(900, 200); + D2 = DHaitam.damage(TPlay); + H2 = DHaitam.getHealth(); + } + + sf::Font MC; + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + sf::Text Rule(L" ", MC, 40); + Rule.setFillColor(sf::Color(255,255,255)); + Rule.setPosition(220, 70); + + sf::RectangleShape HpLineMy(sf::Vector2f(210, 40)); + HpLineMy.setOutlineThickness(3); + HpLineMy.setOutlineColor(sf::Color(150, 0, 3)); + HpLineMy.setFillColor(sf::Color(0, 0, 0, 0)); + HpLineMy.setPosition(180, 500); + sf::RectangleShape HpLine2(sf::Vector2f(210, 40)); + HpLine2.setOutlineThickness(3); + HpLine2.setOutlineColor(sf::Color(150, 0, 3)); + HpLine2.setFillColor(sf::Color(0, 0, 0, 0)); + HpLine2.setPosition(900, 500); + sf::RectangleShape HpDisplayMy(sf::Vector2f(210, 40)); + HpDisplayMy.setOutlineColor(sf::Color(0, 0, 0, 0)); + HpDisplayMy.setFillColor(sf::Color::Red); + HpDisplayMy.setPosition(180, 500); + sf::RectangleShape HpDisplay2(sf::Vector2f(210, 40)); + HpDisplay2.setOutlineColor(sf::Color(0, 0, 0, 0)); + HpDisplay2.setFillColor(sf::Color::Red); + HpDisplay2.setPosition(900, 500); + + bool step = true; + sf::Event event; + while (window.isOpen() && isMenuActive!=1) + { + while (window.pollEvent(event) && isMenuActive == 4 && H2 > 0 && HMy > 0) + { + if (event.type == sf::Event::KeyPressed) + { + if (event.key.code == sf::Keyboard::Space) + { + if (step == true) { + H2 = H2 - DMy; + if (H2 <= 0) { + HpDisplay2.setSize(sf::Vector2f(0, 0)); + window.draw(HpDisplay2); + window.display(); + isMenuActive = 5; + + } + else { + HpDisplay2.setSize(sf::Vector2f(HpDisplay2.getSize().x - (DMy * 2.1), 40)); + step = false; + } + } + else if (step == false) { + HMy = HMy - D2; + if (HMy <= 0) { + HpDisplayMy.setSize(sf::Vector2f(0, 0)); + window.draw(HpDisplayMy); + window.display(); + isMenuActive = 6; + } + else + { + HpDisplayMy.setSize(sf::Vector2f(HpDisplayMy.getSize().x - (D2 * 2.1), 40)); + step = true; + } + } + } + } + + + } + if (event.type == sf::Event::Closed) + window.close(); + + if (isMenuActive == 4) { + window.clear(Color::Black); + window.draw(Sprite1); + window.draw(Sprite2); + window.draw(Sprite3); + window.draw(Sprite4); + window.draw(Sprite12); + window.draw(Sprite22); + window.draw(Sprite32); + window.draw(Sprite42); + window.draw(HpDisplay2); + window.draw(HpDisplayMy); + window.draw(HpLineMy); + window.draw(HpLine2); + window.draw(Rule); + window.display(); + } + + if (isMenuActive == 5) { + sf::Font MC; + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(1000, 620); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(990, 610); + + sf::Text Vic(L"", MC, 80); + Vic.setFillColor(color1); + Vic.setOutlineThickness(5); + Vic.setOutlineColor(color2); + Vic.setPosition(440, 200); + sf::Text Money(L"+100 ", MC, 30); + Money.setFont(MC); + Money.setPosition(450, 400); + Money.setOutlineThickness(4); + Money.setOutlineColor(sf::Color(255, 201, 14)); + Money.setFillColor(sf::Color(255, 242, 0)); + + bool isMouseOver = false; + sf::Vector2i pixelPos = sf::Mouse::getPosition(window); + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + else if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = false; + } + + } + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + + player2.setCoins(100); + player2.SaveGame("data.txt"); + isMenuActive = 1; + } + + } + if (event.type == sf::Event::Closed) + window.close(); + window.display(); + + window.clear(sf::Color::Black); + window.draw(Exit); + window.draw(Vic); + window.draw(exitButton); + window.draw(Money); + } + if (isMenuActive == 6) { + sf::Font MC; + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(1000, 620); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(990, 610); + + sf::Text Fail(L"", MC, 80); + Fail.setFillColor(sf::Color::Red); + Fail.setOutlineThickness(5); + Fail.setOutlineColor(sf::Color(150, 0, 3)); + Fail.setPosition(280, 290); + + + bool isMouseOver = false; + sf::Vector2i pixelPos = sf::Mouse::getPosition(window); + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + else if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = false; + } + + } + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 1; + } + + } + if (event.type == sf::Event::Closed) + window.close(); + window.display(); + + + window.clear(sf::Color::Black); + window.draw(Exit); + window.draw(Fail); + window.draw(exitButton); + } + + } +} diff --git a/sem2/Boyarova/DinoGame3000/Fun.h b/sem2/Boyarova/DinoGame3000/Fun.h new file mode 100644 index 00000000..fe0e2f3a --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Fun.h @@ -0,0 +1,4 @@ +#pragma once +#include + +void Fun(int A, int B, int C, sf::RenderWindow& window); \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/GameInfo.cpp b/sem2/Boyarova/DinoGame3000/GameInfo.cpp new file mode 100644 index 00000000..a3c6d857 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/GameInfo.cpp @@ -0,0 +1,16 @@ +#include "GameInfo.h" +#include "Help.h" +#include +#include +#pragma comment(lib,"shell32") + +using namespace std; + + +void GameInfo() +{ + LPCWSTR open = L"open"; + LPCWSTR url = L"https://youtu.be/dQw4w9WgXcQ?si=3SPKElEZHfXQXglg"; + ShellExecute(NULL, open, url, 0, 0, SW_SHOWNORMAL); + isMenuActive = 1; +} \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/GameInfo.h b/sem2/Boyarova/DinoGame3000/GameInfo.h new file mode 100644 index 00000000..6750c61f --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/GameInfo.h @@ -0,0 +1,8 @@ +#pragma once + +#include +#ifndef GAMEINFO_H +#define GAMEINFO_H + +void GameInfo(); +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/GameMenu.cpp b/sem2/Boyarova/DinoGame3000/GameMenu.cpp new file mode 100644 index 00000000..5c0e0f7d --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/GameMenu.cpp @@ -0,0 +1,153 @@ +#pragma once +#include "Help.h" +#include "GameMenu.h" +#include "Player.h" +#include +#include "Shop.h" +#include +using namespace sf; + + +void DisplayMenu(sf::RenderWindow& window) { + + sf::Font MC; + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + + sf::Text Start(L"", MC, 40); + Start.setFillColor(color1); + Start.setOutlineThickness(5); + Start.setOutlineColor(color2); + Start.setPosition(500, 300); + sf::RectangleShape startButton(sf::Vector2f(260, 55)); + startButton.setFillColor(sf::Color(0, 0, 0, 0)); + startButton.setPosition(490, 290); + + sf::Text Shop(L"", MC, 40); + Shop.setFillColor(color1); + Shop.setOutlineThickness(5); + Shop.setOutlineColor(color2); + Shop.setPosition(478, 370); + sf::RectangleShape shopButton(sf::Vector2f(310, 55)); + shopButton.setFillColor(sf::Color(0, 0, 0, 0)); + shopButton.setPosition(468, 360); + + sf::Text Info(L" ", MC, 40); + Info.setFillColor(color1); + Info.setOutlineThickness(5); + Info.setOutlineColor(color2); + Info.setPosition(490, 440); + sf::RectangleShape infotButton(sf::Vector2f(280, 55)); + infotButton.setFillColor(sf::Color(0, 0, 0, 0)); + infotButton.setPosition(480, 430); + + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(510, 510); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(500, 500); + + Text t_header(L"DinoGame3000", MC, 100); + t_header.setFillColor(Color(0, 193, 0)); + t_header.setOutlineThickness(5); + t_header.setOutlineColor(Color(0, 94, 0)); + t_header.setPosition(60, 50); + + + bool isMouseOver = false; + Vector2i pixelPos = Mouse::getPosition(window); + sf::Event event; + while (window.pollEvent(event)) + { + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + + if (startButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + startButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + if (!startButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + startButton.setFillColor(sf::Color(0, 0, 0, 0)); + isMouseOver = false; + } + + if (shopButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + shopButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + if (!shopButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + shopButton.setFillColor(sf::Color(0, 0, 0, 0)); + isMouseOver = false; + } + + if (infotButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + infotButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + if (!infotButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + infotButton.setFillColor(sf::Color(0, 0, 0, 0)); + isMouseOver = false; + } + + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + isMouseOver = false; + } + } + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + window.close(); + } + if (shopButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 2; + + } + if (infotButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 3; + + } + if (startButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 4; + + } + } + if (event.type == sf::Event::Closed) + window.close(); + window.display(); + } + + window.clear(Color::Black); + window.draw(t_header); + window.draw(Start); + window.draw(Shop); + window.draw(Info); + window.draw(Exit); + window.draw(startButton); + window.draw(shopButton); + window.draw(infotButton); + window.draw(exitButton); + +} diff --git a/sem2/Boyarova/DinoGame3000/GameMenu.h b/sem2/Boyarova/DinoGame3000/GameMenu.h new file mode 100644 index 00000000..76a3e6e8 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/GameMenu.h @@ -0,0 +1,8 @@ +#pragma once + +#include +#ifndef GAMEMENU_H +#define GAMEMENU_H + +void DisplayMenu(sf::RenderWindow& window); +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Help.cpp b/sem2/Boyarova/DinoGame3000/Help.cpp new file mode 100644 index 00000000..6ed01bd8 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Help.cpp @@ -0,0 +1,4 @@ +#pragma once +#include "Help.h" + +int isMenuActive = 1; \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Help.h b/sem2/Boyarova/DinoGame3000/Help.h new file mode 100644 index 00000000..50b861b1 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Help.h @@ -0,0 +1,16 @@ +#pragma once +#ifndef HELP_H +#define HELP_H +#include + +enum Terrain { + Plain, + River, + Mountain +}; + +extern int isMenuActive; + +extern std::vector Balte; + +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Music.h b/sem2/Boyarova/DinoGame3000/Music.h new file mode 100644 index 00000000..6d596a12 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Music.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include +#ifndef MUSIC_H +#define MUSIC_H + +sf::Music BestSongEver; + +void load_music() { + BestSongEver.openFromFile("music/cachemonet.ogg"); + BestSongEver.play(); +} +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Play.cpp b/sem2/Boyarova/DinoGame3000/Play.cpp new file mode 100644 index 00000000..307f296d --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Play.cpp @@ -0,0 +1,209 @@ +#pragma once +#include +#include +#include +#include +#include "Player.h" +#include "Play.h" +#include "Help.h" +#include "Fun.h" + + +Terrain TPlay; + +using namespace sf; + +void Play(sf::RenderWindow& window) { + + sf::Font MC; + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + bool ran = true; + sf::Text Ter; + int random,random2; + if (ran == true) { + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution dis(0, 2); + random = dis(gen); + std::random_device rd2; + std::mt19937 gen2(rd2()); + std::uniform_int_distribution dis2(0, 3); + random2 = dis2(gen); + ran = false; + Ter.setFont(MC); + if (random == 0) { + Ter.setString("Plain"); + Terrain TPlay = Terrain::Plain; + } + if (random == 1) { + Ter.setString("River"); + Terrain TPlay = Terrain::River; + } + if (random == 2) { + Ter.setString("Mountain"); + Terrain TPlay = Terrain::Mountain; + } + } + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + sf::Text Ch(L" ", MC, 70); + Ch.setFillColor(color1); + Ch.setOutlineThickness(5); + Ch.setOutlineColor(color2); + Ch.setPosition(230, 200); + + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(1000, 70); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(990, 60); + + Ter.setCharacterSize(30); + float textWidth = Ter.getLocalBounds().width; + Ter.setPosition((window.getSize().x - textWidth) / 2, 30); + Ter.setOutlineThickness(4); + Ter.setOutlineColor(sf::Color(163, 73, 164)); + Ter.setFillColor(sf::Color(188, 177, 226)); + + Player player1; + player1.LoadGame("data.txt"); + std::vector Info = player1.getInfo(); + + Texture Dino1, Dino2, Dino3, Dino4, Dino12, Dino22, Dino32, Dino42; + Dino1.loadFromFile("images/DCyno.jpg"); + Dino2.loadFromFile("images/DNari.jpg"); + Dino3.loadFromFile("images/DKaveh.jpg"); + Dino4.loadFromFile("images/DHaitam.jpg"); + Dino12.loadFromFile("images/CCyno.jpg"); + Dino22.loadFromFile("images/CNari.jpg"); + Dino32.loadFromFile("images/CKaveh.jpg"); + Dino42.loadFromFile("images/CHaitam.jpg"); + Sprite Sprite1, Sprite2, Sprite3, Sprite4; + + if (Info[0] == true) + Sprite1.setTexture(Dino1); + if (Info[1] == true) + Sprite2.setTexture(Dino2); + if (Info[2] == true) + Sprite3.setTexture(Dino3); + if (Info[3] == true) + Sprite4.setTexture(Dino4); + + Sprite1.setPosition(100, 400); + Sprite2.setPosition(385, 400); + Sprite3.setPosition(670, 400); + Sprite4.setPosition(955, 400); + std::vector Balte = { false, false, false, false }; + bool isMouseOver = false; + while (window.isOpen() && isMenuActive != 1) + { + sf::Event event; + while (window.pollEvent(event)) + { + + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (Sprite1.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + Sprite1.setTexture(Dino12); + isMouseOver = true; + } + else if (Sprite1.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + Sprite1.setTexture(Dino1); + isMouseOver = false; + } + else if (Sprite2.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + Sprite2.setTexture(Dino22); + isMouseOver = true; + } + else if (Sprite2.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + Sprite2.setTexture(Dino2); + isMouseOver = false; + } + + else if (Sprite3.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + Sprite3.setTexture(Dino32); + isMouseOver = true; + } + else if (Sprite3.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + Sprite3.setTexture(Dino3); + isMouseOver = false; + } + + else if (Sprite4.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + Sprite4.setTexture(Dino42); + isMouseOver = true; + } + else if (Sprite4.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + Sprite4.setTexture(Dino4); + isMouseOver = false; + } + else if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + else if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + isMouseOver = false; + } + } + + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 1; + } + else if (Sprite1.getGlobalBounds().contains(sf::Vector2f(mousePos)) && Info[0] == true) + { + Fun(1, random2, random, window); + } + else if (Sprite2.getGlobalBounds().contains(sf::Vector2f(mousePos)) && Info[1] == true) + { + Fun(2, random2, random, window); + } + else if (Sprite3.getGlobalBounds().contains(sf::Vector2f(mousePos)) && Info[2] == true) + { + Fun(3, random2, random, window); + } + else if (Sprite4.getGlobalBounds().contains(sf::Vector2f(mousePos)) && Info[3] == true) + { + Fun(4, random2, random, window); + } + } + if (isMenuActive == 4) { + window.clear(Color::Black); + window.draw(Ter); + window.draw(Sprite1); + window.draw(Sprite2); + window.draw(Sprite3); + window.draw(Sprite4); + window.draw(Ch); + window.draw(Exit); + window.draw(exitButton); + window.display(); + } + + if (event.type == sf::Event::Closed) + window.close(); + + } + } +} + + \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Play.h b/sem2/Boyarova/DinoGame3000/Play.h new file mode 100644 index 00000000..68d23427 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Play.h @@ -0,0 +1,7 @@ +#pragma once +#include +#ifndef PLAY_H +#define PLAY_H + +void Play(sf::RenderWindow& window); +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Player.cpp b/sem2/Boyarova/DinoGame3000/Player.cpp new file mode 100644 index 00000000..a2bd8f91 --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Player.cpp @@ -0,0 +1,43 @@ +#pragma once +#include "Player.h" + +void Player::setCoins(int A) { + coins = coins + A; +} +int Player::getCoins() { + return coins; +} +void Player::buy(int A) { + coins = coins - A; +} + +std::vector Player::getInfo() { + return Dinos; +} +void Player::setDino(std::vector B) { + Dinos = B; +} + +void Player:: LoadGame(const std::string& filename) { + std::ifstream file(filename); + Dinos.clear(); + if (file.is_open()) { + file >> coins; + for (int i = 0; i < 4; i++) { + bool s; + file >> s; + Dinos.push_back(s); + } + } +} +void Player::SaveGame(const std::string& filename) { + std::remove("data.txt"); + std::ofstream file(filename, std::ios::trunc); + if (file.is_open()) { + file << coins << std::endl; + for (int i = 0; i < Dinos.size(); i++) { + bool s = Dinos.at(i); + file << s << std::endl; + } + } +} \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Player.h b/sem2/Boyarova/DinoGame3000/Player.h new file mode 100644 index 00000000..145ac40e --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Player.h @@ -0,0 +1,25 @@ +#pragma once +#ifndef PLAYER_H +#define PLAYER_H +#include +#include +#include +#include + + +class Player { +private: + int coins = 400; + std::vector Dinos = { false, false, false, false }; +public: + void setCoins(int A); + int getCoins(); + void buy(int A); + std::vector getInfo(); + void setDino(std::vector B); + void LoadGame(const std::string& filename); + void SaveGame(const std::string& filename); + +}; +extern Player player; +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Shop.cpp b/sem2/Boyarova/DinoGame3000/Shop.cpp new file mode 100644 index 00000000..0776a6de --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Shop.cpp @@ -0,0 +1,217 @@ +#pragma once +#include "Shop.h" +#include "Help.h" +#include "Player.h" +#include +using namespace sf; + + +void GameShop(sf::RenderWindow& window) +{ + Player player; + player.LoadGame("data.txt"); + static int B = player.getCoins(); + std::vector Info = player.getInfo(); + int price = 200; + + sf::Font MC; + sf::Color color1 = sf::Color(4, 255, 67); + sf::Color color2 = sf::Color(0, 202, 51); + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); + sf::Text Exit(L"", MC, 40); + Exit.setFillColor(color1); + Exit.setOutlineThickness(5); + Exit.setOutlineColor(color2); + Exit.setPosition(1000, 620); + sf::RectangleShape exitButton(sf::Vector2f(240, 55)); + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + exitButton.setPosition(990, 610); + + + std::ostringstream Bal; + Bal << player.getCoins(); + sf::Text Balance; + Balance.setFont(MC); + Balance.setString(L": " + Bal.str()); + Balance.setCharacterSize(24); + Balance.setPosition(50, 660); + Balance.setOutlineThickness(4); + Balance.setOutlineColor(sf::Color(255, 201, 14)); + Balance.setFillColor(sf::Color(255, 242, 0)); + + sf::Text TDino1(L"200", MC, 20); + TDino1.setFont(MC); + TDino1.setPosition(170, 500); + TDino1.setOutlineThickness(4); + TDino1.setOutlineColor(sf::Color(255, 201, 14)); + TDino1.setFillColor(sf::Color(255, 242, 0)); + sf::Text TDino2(L"200", MC, 20); + TDino2.setFont(MC); + TDino2.setPosition(455, 500); + TDino2.setOutlineThickness(4); + TDino2.setOutlineColor(sf::Color(255, 201, 14)); + TDino2.setFillColor(sf::Color(255, 242, 0)); + sf::Text TDino3(L"200", MC, 20); + TDino3.setFont(MC); + TDino3.setPosition(740, 500); + TDino3.setOutlineThickness(4); + TDino3.setOutlineColor(sf::Color(255, 201, 14)); + TDino3.setFillColor(sf::Color(255, 242, 0)); + sf::Text TDino4(L"200", MC, 20); + TDino4.setFont(MC); + TDino4.setPosition(1025, 500); + TDino4.setOutlineThickness(4); + TDino4.setOutlineColor(sf::Color(255, 201, 14)); + TDino4.setFillColor(sf::Color(255, 242, 0)); + + + Texture Dino1, Dino2, Dino3, Dino4, Dino12, Dino22, Dino32, Dino42, Dino13, Dino23, Dino33, Dino43; + Dino1.loadFromFile("images/DCyno.jpg"); + Dino2.loadFromFile("images/DNari.jpg"); + Dino3.loadFromFile("images/DKaveh.jpg"); + Dino4.loadFromFile("images/DHaitam.jpg"); + Dino12.loadFromFile("images/CCyno.jpg"); + Dino22.loadFromFile("images/CNari.jpg"); + Dino32.loadFromFile("images/CKaveh.jpg"); + Dino42.loadFromFile("images/CHaitam.jpg"); + Dino13.loadFromFile("images/BCyno.jpg"); + Dino23.loadFromFile("images/BNari.jpg"); + Dino33.loadFromFile("images/BKaveh.jpg"); + Dino43.loadFromFile("images/BHaitam.jpg"); + Sprite Sprite1, Sprite2, Sprite3, Sprite4; + + if(Info[0] == false) + Sprite1.setTexture(Dino1); + else Sprite1.setTexture(Dino13); + if (Info[1] == false) + Sprite2.setTexture(Dino2); + else Sprite2.setTexture(Dino23); + if (Info[2] == false) + Sprite3.setTexture(Dino3); + else Sprite3.setTexture(Dino33); + if (Info[3] == false) + Sprite4.setTexture(Dino4); + else Sprite4.setTexture(Dino43); + + Sprite1.setPosition(100, 200); + Sprite2.setPosition(385, 200); + Sprite3.setPosition(670, 200); + Sprite4.setPosition(955, 200); + + bool isMouseOver = false; + Vector2i pixelPos = Mouse::getPosition(window); + sf::Event event; + while (window.pollEvent(event) && isMenuActive == 2) + { + if (event.type == sf::Event::MouseMoved) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 150)); + isMouseOver = true; + } + else if (!exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver) + { + exitButton.setFillColor(sf::Color(0, 0, 0, 0)); + isMouseOver = false; + } + + else if (Sprite1.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver && Info[0] == false) + { + Sprite1.setTexture(Dino12); + isMouseOver = true; + } + else if (Sprite1.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver && Info[0] == false) + { + Sprite1.setTexture(Dino1); + isMouseOver = false; + } + + else if (Sprite2.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver && Info[1] == false) + { + Sprite2.setTexture(Dino22); + isMouseOver = true; + } + else if (Sprite2.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver && Info[1] == false) + { + Sprite1.setTexture(Dino2); + isMouseOver = false; + } + else if (Sprite3.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver && Info[2] == false) + { + Sprite3.setTexture(Dino32); + isMouseOver = true; + } + else if (Sprite3.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver && Info[2] == false) + { + Sprite3.setTexture(Dino3); + isMouseOver = false; + } + + else if (Sprite4.getGlobalBounds().contains(sf::Vector2f(mousePos)) && !isMouseOver && Info[3] == false) + { + Sprite4.setTexture(Dino42); + isMouseOver = true; + } + else if (Sprite4.getGlobalBounds().contains(sf::Vector2f(mousePos)) && isMouseOver && Info[3] == false) + { + Sprite4.setTexture(Dino4); + isMouseOver = false; + } + } + if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + if (exitButton.getGlobalBounds().contains(sf::Vector2f(mousePos))) + { + isMenuActive = 1; + } + else if (Sprite1.getGlobalBounds().contains(sf::Vector2f(mousePos))&& player.getCoins()>=price && Info[0] == false) + { + Info[0] = true; + player.setDino(Info); + player.buy(price); + player.SaveGame("data.txt"); + } + else if (Sprite2.getGlobalBounds().contains(sf::Vector2f(mousePos)) && player.getCoins() >= price && Info[1] == false) + { + Info[1] = true; + player.setDino(Info); + player.buy(price); + player.SaveGame("data.txt"); + } + else if (Sprite3.getGlobalBounds().contains(sf::Vector2f(mousePos)) && player.getCoins() >= price && Info[2] == false) + { + Info[2] = true; + player.setDino(Info); + player.buy(price); + player.SaveGame("data.txt"); + } + else if (Sprite4.getGlobalBounds().contains(sf::Vector2f(mousePos)) && player.getCoins() >= price && Info[3] == false) + { + Info[3] = true; + player.setDino(Info); + player.buy(price); + player.SaveGame("data.txt"); + } + } + if (event.type == sf::Event::Closed) + window.close(); + window.display(); + } + + window.clear(Color::Black); + window.draw(Exit); + window.draw(exitButton); + window.draw(Sprite1); + window.draw(Sprite2); + window.draw(Sprite3); + window.draw(Sprite4); + window.draw(Balance); + window.draw(TDino1); + window.draw(TDino2); + window.draw(TDino3); + window.draw(TDino4); + +} \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Shop.h b/sem2/Boyarova/DinoGame3000/Shop.h new file mode 100644 index 00000000..19ead62a --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Shop.h @@ -0,0 +1,7 @@ +#pragma once +#include +#ifndef SHOP_H +#define SHOP_H + +void GameShop(sf::RenderWindow& window); +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/Text.h b/sem2/Boyarova/DinoGame3000/Text.h new file mode 100644 index 00000000..747c3f2e --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/Text.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include +#ifndef TEXT_H +#define TEXT_H + +sf::Font MC; + +void load_fonts() { + MC.loadFromFile("font/minecraft_title_cyrillic.ttf"); +} +#endif \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/data.txt b/sem2/Boyarova/DinoGame3000/data.txt new file mode 100644 index 00000000..32d4a09e --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/data.txt @@ -0,0 +1,5 @@ +500 +0 +0 +0 +0 diff --git a/sem2/Boyarova/DinoGame3000/font/minecraft_title_cyrillic.ttf b/sem2/Boyarova/DinoGame3000/font/minecraft_title_cyrillic.ttf new file mode 100644 index 00000000..91893245 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/font/minecraft_title_cyrillic.ttf differ diff --git a/sem2/Boyarova/DinoGame3000/images/BCyno.jpg b/sem2/Boyarova/DinoGame3000/images/BCyno.jpg new file mode 100644 index 00000000..98afa5d3 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/BCyno.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/BHaitam.jpg b/sem2/Boyarova/DinoGame3000/images/BHaitam.jpg new file mode 100644 index 00000000..c8d1f259 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/BHaitam.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/BKaveh.jpg b/sem2/Boyarova/DinoGame3000/images/BKaveh.jpg new file mode 100644 index 00000000..1366b7b0 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/BKaveh.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/BNari.jpg b/sem2/Boyarova/DinoGame3000/images/BNari.jpg new file mode 100644 index 00000000..435e1f0d Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/BNari.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/CCyno.jpg b/sem2/Boyarova/DinoGame3000/images/CCyno.jpg new file mode 100644 index 00000000..01c2c261 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/CCyno.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/CHaitam.jpg b/sem2/Boyarova/DinoGame3000/images/CHaitam.jpg new file mode 100644 index 00000000..f897fcba Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/CHaitam.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/CKaveh.jpg b/sem2/Boyarova/DinoGame3000/images/CKaveh.jpg new file mode 100644 index 00000000..0191ea19 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/CKaveh.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/CNari.jpg b/sem2/Boyarova/DinoGame3000/images/CNari.jpg new file mode 100644 index 00000000..36d53311 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/CNari.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/DCyno.jpg b/sem2/Boyarova/DinoGame3000/images/DCyno.jpg new file mode 100644 index 00000000..0ce19ca5 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/DCyno.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/DHaitam.jpg b/sem2/Boyarova/DinoGame3000/images/DHaitam.jpg new file mode 100644 index 00000000..03a63d70 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/DHaitam.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/DKaveh.jpg b/sem2/Boyarova/DinoGame3000/images/DKaveh.jpg new file mode 100644 index 00000000..caf0e4ce Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/DKaveh.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/DNari.jpg b/sem2/Boyarova/DinoGame3000/images/DNari.jpg new file mode 100644 index 00000000..142ccfc9 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/DNari.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/Test.jpg b/sem2/Boyarova/DinoGame3000/images/Test.jpg new file mode 100644 index 00000000..4049f2d4 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/Test.jpg differ diff --git a/sem2/Boyarova/DinoGame3000/images/TestSrite 3545.png b/sem2/Boyarova/DinoGame3000/images/TestSrite 3545.png new file mode 100644 index 00000000..47396089 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/TestSrite 3545.png differ diff --git a/sem2/Boyarova/DinoGame3000/images/TestSrite2 3545.png b/sem2/Boyarova/DinoGame3000/images/TestSrite2 3545.png new file mode 100644 index 00000000..4e95a453 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/images/TestSrite2 3545.png differ diff --git a/sem2/Boyarova/DinoGame3000/main.cpp b/sem2/Boyarova/DinoGame3000/main.cpp new file mode 100644 index 00000000..2d06680f --- /dev/null +++ b/sem2/Boyarova/DinoGame3000/main.cpp @@ -0,0 +1,57 @@ +#pragma once +#include "Player.h" +#include "Help.h" +#include "GameMenu.h" +#include +#include +#include +#include +#include "Text.h" +#include "Music.h" +#include "Shop.h" +#include "GameInfo.h" +#include "Play.h" +#include "Fun.h" +#include "End.h" + +using namespace sf; + +int main() +{ + RenderWindow window(VideoMode(1280, 720), "GodHelpMe"); + load_fonts(); + load_music(); + Player player; + BestSongEver.setLoop(true); + player.LoadGame("data.txt"); + + + + while (window.isOpen()) + { + if (isMenuActive == 1) + { + DisplayMenu(window); + + } + else if (isMenuActive == 2) + { + GameShop(window); + + } + else if (isMenuActive == 3) + { + GameInfo(); + + } + else if (isMenuActive == 4) + { + Play(window); + + } + + + } + + return 0; +} \ No newline at end of file diff --git a/sem2/Boyarova/DinoGame3000/music/cachemonet.ogg b/sem2/Boyarova/DinoGame3000/music/cachemonet.ogg new file mode 100644 index 00000000..93a2ea56 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/music/cachemonet.ogg differ diff --git a/sem2/Boyarova/DinoGame3000/openal32.dll b/sem2/Boyarova/DinoGame3000/openal32.dll new file mode 100644 index 00000000..7760c05f Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/openal32.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-audio-2.dll b/sem2/Boyarova/DinoGame3000/sfml-audio-2.dll new file mode 100644 index 00000000..a180800e Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-audio-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-audio-d-2.dll b/sem2/Boyarova/DinoGame3000/sfml-audio-d-2.dll new file mode 100644 index 00000000..7d8b7923 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-audio-d-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-graphics-2.dll b/sem2/Boyarova/DinoGame3000/sfml-graphics-2.dll new file mode 100644 index 00000000..af9c6db0 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-graphics-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-graphics-d-2.dll b/sem2/Boyarova/DinoGame3000/sfml-graphics-d-2.dll new file mode 100644 index 00000000..20eef4da Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-graphics-d-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-network-2.dll b/sem2/Boyarova/DinoGame3000/sfml-network-2.dll new file mode 100644 index 00000000..a98f7433 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-network-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-network-d-2.dll b/sem2/Boyarova/DinoGame3000/sfml-network-d-2.dll new file mode 100644 index 00000000..708fc717 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-network-d-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-system-2.dll b/sem2/Boyarova/DinoGame3000/sfml-system-2.dll new file mode 100644 index 00000000..db1fc198 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-system-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-system-d-2.dll b/sem2/Boyarova/DinoGame3000/sfml-system-d-2.dll new file mode 100644 index 00000000..1d403457 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-system-d-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-window-2.dll b/sem2/Boyarova/DinoGame3000/sfml-window-2.dll new file mode 100644 index 00000000..025e5256 Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-window-2.dll differ diff --git a/sem2/Boyarova/DinoGame3000/sfml-window-d-2.dll b/sem2/Boyarova/DinoGame3000/sfml-window-d-2.dll new file mode 100644 index 00000000..450c67be Binary files /dev/null and b/sem2/Boyarova/DinoGame3000/sfml-window-d-2.dll differ