diff --git a/sem2/AntonovVV/DINO WAR/AssetManager.cpp b/sem2/AntonovVV/DINO WAR/AssetManager.cpp new file mode 100644 index 00000000..78c59924 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/AssetManager.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include "AssetManager.hpp" + +AssetManager* AssetManager::sInstance = nullptr; + +AssetManager::AssetManager() +{ + // Разрешить существование только одного AssetManager + // В противном случае сгенерировать исключение + + sInstance = this; +} +sf::Texture& AssetManager::GetTexture(std::string const& filename) +{ + auto& texMap = sInstance->m_Textures; + + auto pairFound = texMap.find(filename); + + if (pairFound != texMap.end()) + { + return pairFound->second; + } + else + { + auto& texture = texMap[filename]; + texture.loadFromFile(filename); + return texture; + } + +} diff --git a/sem2/AntonovVV/DINO WAR/AssetManager.hpp b/sem2/AntonovVV/DINO WAR/AssetManager.hpp new file mode 100644 index 00000000..6aef3bbe --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/AssetManager.hpp @@ -0,0 +1,26 @@ + +#ifndef AssetManager_hpp +#define AssetManager_hpp +#include +#include +#include +#include + +class AssetManager +{ + +public: + AssetManager(); + + static sf::Texture& GetTexture(std::string const& filename); + static sf::SoundBuffer& GetSoundBuffer(std::string const& filename); + static sf::Font& GetFont(std::string const& filename); +private: + + std::map m_Textures; + std::map m_SoundBuffer; + std::map m_Fonts; + + static AssetManager* sInstance; +}; +#endif /* AssetManager_hpp */ diff --git a/sem2/AntonovVV/DINO WAR/Battle.cpp b/sem2/AntonovVV/DINO WAR/Battle.cpp new file mode 100644 index 00000000..0254090a --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Battle.cpp @@ -0,0 +1,422 @@ +#include "AssetManager.hpp" +#include "Menu.h" +#include +#include +#include "Dino.h" +#include "Player.h" + +void idleAnimation(sf::Sprite &sprite, std::string output){ + sprite.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/"+ output +"/base/idle.png")); +} + +void Battle(){ + + AssetManager manager; + bool needToDrawEnemyGrave = false; + bool needToDrawMyGrave = false; + + int killCounter = 0; + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + + sf::Texture textureBackgroundPlain; + textureBackgroundPlain.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + + sf::Texture textureBackgroundMountain; + textureBackgroundMountain.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Mountain.jpg"); + + sf::Texture textureBackgroundRiver; + textureBackgroundRiver.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/River.jpg"); + + std::srand(std::time(0)); + Terrain randomTerrain = static_cast(std::rand() % 3); + sf::Sprite spriteBackground; + switch (randomTerrain) { + case Plain: + spriteBackground.setTexture(textureBackgroundPlain); + break; + case River: + spriteBackground.setTexture(textureBackgroundRiver); + break; + case Mountain: + spriteBackground.setTexture(textureBackgroundMountain); + break; + } + + start: + std::map map; + map["Kira"] = 0; + map["Kuro"] = 1; + map["Mort"] = 2; + map["Olaf"] = 3; + + DeathMyDino: + std::string myDinoOutput = player.vecPull[rand()%player.vecPull.size()]; + sf::Vector2i spriteSize(24,24); + sf::Sprite myDino; + myDino.setScale(sf::Vector2f(7.0f, 7.0f)); + myDino.setPosition(600,500); + int frameNum = 3; + float animationDuration = 1; + + + DeathEnemyDino: + idleAnimation(myDino, myDinoOutput); + std::string enemyDinoOutput = player.vecPull[rand()%player.vecPull.size()]; + sf::Sprite enemyDino; + idleAnimation(enemyDino, enemyDinoOutput); + enemyDino.setScale(sf::Vector2f(-7.0f,7.0f)); + enemyDino.setPosition(1200,500); + + sf::Texture greenLine; + sf::Sprite greenLineSprite; + greenLine.loadFromFile( "C:/Users/Asus/CLionProjects/HelloSFML/greenbarUpper.png" ); + greenLineSprite.setPosition( 630, 465 ); + greenLineSprite.setTexture( greenLine ); + + sf::Time elapsedTime; + sf::Clock clock; + + sf::Texture greenLineEnemy; + sf::Sprite greenLineSpriteEnemy; + greenLineEnemy.loadFromFile( "C:/Users/Asus/CLionProjects/HelloSFML/greenbarUpper.png" ); + greenLineSpriteEnemy.setPosition( 1035, 465 ); + greenLineSpriteEnemy.setTexture( greenLineEnemy ); + + sf::Text battleTitle("Press enter to smash!", font); + battleTitle.setFillColor(sf::Color::Green); + battleTitle.setPosition(450, 60); + battleTitle.setCharacterSize(70); + + Kira kira = Kira(); + Kira kiraEnemy = Kira(); + Kuro kuro = Kuro(); + Kuro kuroEnemy = Kuro(); + Mort mort = Mort(); + Mort mortEnemy = Mort(); + Olaf olaf = Olaf(); + Olaf olafEnemy = Olaf(); + + bool needToDrawEnemy = true; + if ( killCounter == 3) { + window.close(); + Winner(); + } + if (player.vecPull.size() == 0) { + loose: + window.close(); + Looser(); + } + + while (window.isOpen()) { + + sf::Event Event; + window.clear(); + window.draw(spriteBackground); + sf::Time deltaTime = clock.restart(); + elapsedTime += deltaTime; + float timeAsSecond = elapsedTime.asSeconds(); + + int animFrame = static_cast((timeAsSecond/animationDuration)* static_cast(frameNum))% frameNum; + + myDino.setTextureRect(sf::IntRect(animFrame*spriteSize.x,0,spriteSize.x,spriteSize.y)); + enemyDino.setTextureRect(sf::IntRect(animFrame*spriteSize.x,0,spriteSize.x,spriteSize.y)); + window.draw(myDino); + if (animFrame == frameNum - 1 && timeAsSecond >= 1.25f) { + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/idle.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/idle.png")); + } + window.draw(greenLineSprite); + if (needToDrawEnemy == true) { + window.draw(greenLineSpriteEnemy); + window.draw(enemyDino); + } + window.draw(battleTitle); + std::string myDinoPicked; + switch (map[myDinoOutput]) { + case 0: + myDinoPicked = "Kira"; + break; + case 1: + myDinoPicked = "Kuro"; + break; + case 2: + myDinoPicked = "Mort"; + break; + case 3: + myDinoPicked = "Olaf"; + break; + } + window.display(); + while (window.pollEvent(Event)) { + switch (Event.type) { + case sf::Event::KeyPressed: + switch (map[enemyDinoOutput]) { + case 0: + if (greenLineSpriteEnemy.getScale().x > 0.28 && greenLineSprite.getScale().x > 0.25) + { + if (myDinoPicked == "Kira") { + kiraEnemy.HP = kiraEnemy.HP - kira.damage(randomTerrain); + kira.HP = kira.HP - kiraEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kiraEnemy.HP/100, 1); + greenLineSprite.setScale(kira.HP/100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Kuro") { + kiraEnemy.HP = kiraEnemy.HP - kuro.damage(randomTerrain); + kuro.HP = kuro.HP - kiraEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kiraEnemy.HP/100, 1); + greenLineSprite.setScale(kuro.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Mort") { + kiraEnemy.HP = kiraEnemy.HP - mort.damage(randomTerrain); + mort.HP = mort.HP - kiraEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kiraEnemy.HP/100, 1); + greenLineSprite.setScale(mort.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Olaf") { + kiraEnemy.HP = kiraEnemy.HP - olaf.damage(randomTerrain); + olaf.HP = olaf.HP - kiraEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kiraEnemy.HP/100, 1); + greenLineSprite.setScale(olaf.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + } + else + { + ++killCounter; + needToDrawEnemyGrave = true; + goto DeathEnemyDino; + } + if (greenLineSprite.getScale().x == greenLineSpriteEnemy.getScale().x && greenLineSprite.getScale().x < 0.25) { + ++killCounter; + needToDrawMyGrave = true; + needToDrawEnemyGrave = true; + if (player.vecPull.size()!=0) { + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + if (player.vecPull.size() == 0) { + goto loose; + } + goto start; + } + + if(greenLineSprite.getScale().x < 0.25) + { + if (player.vecPull.size()!=0) { + needToDrawMyGrave = true; + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + goto DeathMyDino; + } + break; + + case 1: + if (greenLineSpriteEnemy.getScale().x > 0.28 && greenLineSprite.getScale().x > 0.25) + { + if (myDinoPicked == "Kira") { + kuroEnemy.HP = kuroEnemy.HP - kira.damage(randomTerrain); + kira.HP = kira.HP - kuroEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kuroEnemy.HP / 100, 1); + greenLineSprite.setScale(kira.HP/100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Kuro") { + kuroEnemy.HP = kuroEnemy.HP - kuro.damage(randomTerrain); + kuro.HP = kuro.HP - kuroEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kuroEnemy.HP / 100, 1); + greenLineSprite.setScale(kuro.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Mort") { + kuroEnemy.HP = kuroEnemy.HP - mort.damage(randomTerrain); + mort.HP = mort.HP - kuroEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kuroEnemy.HP / 100, 1); + greenLineSprite.setScale(mort.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Olaf") { + kuroEnemy.HP = kuroEnemy.HP - olaf.damage(randomTerrain); + olaf.HP = olaf.HP - kuroEnemy.damage(randomTerrain); + greenLineSpriteEnemy.setScale(kuroEnemy.HP / 100, 1); + greenLineSprite.setScale(olaf.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + } + else + { + ++killCounter; + needToDrawEnemy = false; + needToDrawEnemyGrave = true; + goto DeathEnemyDino; + } + if (greenLineSprite.getScale().x == greenLineSpriteEnemy.getScale().x && greenLineSprite.getScale().x < 0.25) { + ++killCounter; + needToDrawMyGrave = true; + needToDrawEnemyGrave = true; + if (player.vecPull.size()!=0) { + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + if (player.vecPull.size() == 0) { + goto loose; + } + goto start; + } + if(greenLineSprite.getScale().x < 0.25) + { + if (player.vecPull.size()!=0) { + needToDrawMyGrave = true; + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + goto DeathMyDino; + } + break; + + case 2: + if (greenLineSpriteEnemy.getScale().x > 0.28 && greenLineSprite.getScale().x > 0.25) + { + if (myDinoPicked == "Kira") { + mortEnemy.HP = mortEnemy.HP - kira.damage(randomTerrain); + greenLineSpriteEnemy.setScale(mortEnemy.HP / 100, 1); + kira.HP = kira.HP - mortEnemy.damage(randomTerrain); + greenLineSprite.setScale(kira.HP/100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Kuro") { + mortEnemy.HP = mortEnemy.HP - kuro.damage(randomTerrain); + greenLineSpriteEnemy.setScale(mortEnemy.HP / 100, 1); + kuro.HP = kuro.HP - mortEnemy.damage(randomTerrain); + greenLineSprite.setScale(kuro.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Mort") { + mortEnemy.HP = mortEnemy.HP - mort.damage(randomTerrain); + greenLineSpriteEnemy.setScale(mortEnemy.HP / 100, 1); + mort.HP = mort.HP - mortEnemy.damage(randomTerrain); + greenLineSprite.setScale(mort.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Olaf") { + mortEnemy.HP = mortEnemy.HP - olaf.damage(randomTerrain); + greenLineSpriteEnemy.setScale(mortEnemy.HP / 100, 1); + olaf.HP = olaf.HP - mortEnemy.damage(randomTerrain); + greenLineSprite.setScale(olaf.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + } + else + { + ++killCounter; + needToDrawEnemy = false; + needToDrawEnemyGrave = true; + goto DeathEnemyDino; + } + if (greenLineSprite.getScale().x == greenLineSpriteEnemy.getScale().x && greenLineSprite.getScale().x < 0.25) { + ++killCounter; + needToDrawMyGrave = true; + needToDrawEnemyGrave = true; + if (player.vecPull.size()!=0) { + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + if (player.vecPull.size() == 0) { + goto loose; + } + goto start; + } + if(greenLineSprite.getScale().x < 0.25) + { + if (player.vecPull.size()!=0) { + needToDrawMyGrave = true; + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + goto DeathMyDino; + } + break; + + case 3: + if (greenLineSpriteEnemy.getScale().x > 0.28 && greenLineSprite.getScale().x > 0.25) + { + if (myDinoPicked == "Kira") { + olafEnemy.HP = olafEnemy.HP - kira.damage(randomTerrain); + greenLineSpriteEnemy.setScale(olafEnemy.HP / 100, 1); + kira.HP = kira.HP - olafEnemy.damage(randomTerrain); + greenLineSprite.setScale(kira.HP/100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Kuro") { + olafEnemy.HP = olafEnemy.HP - kuro.damage(randomTerrain); + greenLineSpriteEnemy.setScale(olafEnemy.HP / 100, 1); + kuro.HP = kuro.HP - olafEnemy.damage(randomTerrain); + greenLineSprite.setScale(kuro.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Mort") { + olafEnemy.HP = olafEnemy.HP - mort.damage(randomTerrain); + greenLineSpriteEnemy.setScale(olafEnemy.HP / 100, 1); + mort.HP = mort.HP - olafEnemy.damage(randomTerrain); + greenLineSprite.setScale(mort.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + if (myDinoPicked == "Olaf") { + olafEnemy.HP = olafEnemy.HP - olaf.damage(randomTerrain); + greenLineSpriteEnemy.setScale(olafEnemy.HP / 100, 1); + olaf.HP = olaf.HP - olafEnemy.damage(randomTerrain); + greenLineSprite.setScale(olaf.HP / 100, 1); + myDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + myDinoOutput + "/base/hurt.png")); + enemyDino.setTexture(AssetManager::GetTexture("C:/Users/Asus/CLionProjects/HelloSFML/" + enemyDinoOutput + "/base/hurt.png")); + } + } + else + { + ++killCounter; + needToDrawEnemy = false; + needToDrawEnemyGrave = true; + goto DeathEnemyDino; + } + if (greenLineSprite.getScale().x == greenLineSpriteEnemy.getScale().x && greenLineSprite.getScale().x < 0.25) { + ++killCounter; + needToDrawMyGrave = true; + needToDrawEnemyGrave = true; + if (player.vecPull.size()!=0) { + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + if (player.vecPull.size() == 0) { + goto loose; + } + goto start; + } + if(greenLineSprite.getScale().x < 0.25) + { + if (player.vecPull.size()!=0) { + needToDrawMyGrave = true; + player.vecPull.erase( std::remove(player.vecPull.begin(), player.vecPull.end(), myDinoPicked), player.vecPull.end() ); + } + goto DeathMyDino; + } + break; + } + break; + } + } + } +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/BattleMenu.cpp b/sem2/AntonovVV/DINO WAR/BattleMenu.cpp new file mode 100644 index 00000000..67afb508 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/BattleMenu.cpp @@ -0,0 +1,309 @@ +#include "Menu.h" +#include +#include +#include "Dino.h" +#include "Player.h" + +void Battle_Menu() +{ + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + + sf::Texture img; + img.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + sf::Sprite sprite(img); + + sf::Text readyButton; + readyButton.setFont(font ); + readyButton.setStyle(sf::Text::Regular ); + readyButton.setString("Ready?"); + readyButton.setFillColor(sf::Color::White); + readyButton.setCharacterSize(75); + readyButton.setPosition(sf::Vector2f(900, 935)); + + sf::Text text; + text.setFont(font); + text.setString("Pick 3 your dinos"); + text.setCharacterSize(75); + text.setFillColor(sf::Color::White); + text.setPosition(sf::Vector2f(700, 935)); + + sf::Text kiraText; + kiraText.setString("Kira"); + kiraText.setFont(font); + kiraText.setFillColor(sf::Color::Green); + kiraText.setCharacterSize(40); + kiraText.setPosition(710,80); + + sf::Text kuroText; + kuroText.setString("Kuro"); + kuroText.setFont(font); + kuroText.setFillColor(sf::Color::Green); + kuroText.setCharacterSize(40); + kuroText.setPosition(710,250); + + sf::Text mortText; + mortText.setString("Mort"); + mortText.setFont(font); + mortText.setFillColor(sf::Color::Green); + mortText.setCharacterSize(40); + mortText.setPosition(710,420); + + sf::Text olafText; + olafText.setString("Olaf"); + olafText.setFont(font); + olafText.setFillColor(sf::Color::Green); + olafText.setCharacterSize(40); + olafText.setPosition(710,590); + + sf::Texture dinoKiraTexture; + dinoKiraTexture.loadFromFile( "C:/Users/Asus/CLionProjects/HelloSFML/kira/base/idle.png"); + sf::Sprite dinoKiraSprite(dinoKiraTexture,sf::IntRect(0,0,24,24)); + dinoKiraSprite.setPosition(650, 100); + dinoKiraSprite.setScale(sf::Vector2f(7.0f,7.0f)); + + sf::Texture dinoKuroTexture; + dinoKuroTexture.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/kuro/base/idle.png" ); + sf::Sprite dinoKuroSprite(dinoKuroTexture, sf::IntRect(0, 0, 24, 24)); + dinoKuroSprite.setPosition(650, 270); + dinoKuroSprite.setScale(sf::Vector2f(7.0f, 7.0f)); + + sf::Texture dinoMortTexture; + dinoMortTexture.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/mort/base/idle.png" ); + sf::Sprite dinoMortSprite(dinoMortTexture, sf::IntRect(0, 0, 24, 24)); + dinoMortSprite.setPosition(650, 440); + dinoMortSprite.setScale(sf::Vector2f(7.0f, 7.0f)); + + sf::Texture dinoOlafTexture; + dinoOlafTexture.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/olaf/base/idle.png" ); + sf::Sprite dinoOlafSprite(dinoOlafTexture, sf::IntRect(0, 0, 24, 24)); + dinoOlafSprite.setPosition(650, 610); + dinoOlafSprite.setScale(sf::Vector2f(7.0f,7.0f)); + + sf::Text dinoKiraCharacteristics("Strength - " + std::to_string(Kira().STRENGTH) + "\nDexteriry - " + std::to_string(Kira().DEXTERITY) + "\nIntelegience - " + std::to_string(Kira().INTELLIGENCE), font, 40); + dinoKiraCharacteristics.setFillColor(sf::Color::White); + dinoKiraCharacteristics.setStyle(sf::Text::Bold); + dinoKiraCharacteristics.setPosition(sf::Vector2f(850,115)); + + sf::Text dinoKuroCharacteristics("Strength - " + std::to_string(Kuro().STRENGTH) + "\nDexteriry - " + std::to_string(Kuro().DEXTERITY) + "\nIntelegience - " + std::to_string(Kuro().INTELLIGENCE), font, 40); + dinoKuroCharacteristics.setFillColor(sf::Color::White); + dinoKuroCharacteristics.setStyle(sf::Text::Bold); + dinoKuroCharacteristics.setPosition(sf::Vector2f(850, 285)); + + sf::Text dinoMortCharacteristics("Strength - " + std::to_string(Mort().STRENGTH) + "\nDexteriry - " + std::to_string(Mort().DEXTERITY) + "\nIntelegience - " + std::to_string(Mort().INTELLIGENCE), font, 40); + dinoMortCharacteristics.setFillColor(sf::Color::White); + dinoMortCharacteristics.setStyle(sf::Text::Bold); + dinoMortCharacteristics.setPosition(sf::Vector2f(850, 455)); + + sf::Text dinoOlafCharacteristics("Strength - " + std::to_string(Olaf().STRENGTH) + "\nDexteriry - " + std::to_string(Olaf().DEXTERITY) + "\nIntelegience - " + std::to_string(Olaf().INTELLIGENCE), font, 40); + dinoOlafCharacteristics.setFillColor(sf::Color::White); + dinoOlafCharacteristics.setStyle(sf::Text::Bold); + dinoOlafCharacteristics.setPosition(sf::Vector2f(850, 625)); + + + sf::Text pickButtonKira; + pickButtonKira.setFont(font ); + pickButtonKira.setStyle(sf::Text::Regular ); + pickButtonKira.setString("pick"); + pickButtonKira.setFillColor(sf::Color::White); + pickButtonKira.setCharacterSize(55 ); + pickButtonKira.setPosition(sf::Vector2f(1250, 145)); + + sf::Text pickButtonKuro; + pickButtonKuro.setFont(font ); + pickButtonKuro.setStyle(sf::Text::Regular ); + pickButtonKuro.setString("pick" ); + pickButtonKuro.setFillColor(sf::Color::White ); + pickButtonKuro.setCharacterSize(55 ); + pickButtonKuro.setPosition(sf::Vector2f(1250, 290)); + + sf::Text pickButtonMort; + pickButtonMort.setFont(font ); + pickButtonMort.setStyle(sf::Text::Regular ); + pickButtonMort.setString("pick" ); + pickButtonMort.setFillColor(sf::Color::White ); + pickButtonMort.setCharacterSize(55 ); + pickButtonMort.setPosition(sf::Vector2f(1250, 470)); + + sf::Text pickButtonOlaf; + pickButtonOlaf.setFont(font ); + pickButtonOlaf.setStyle(sf::Text::Regular ); + pickButtonOlaf.setString("pick" ); + pickButtonOlaf.setFillColor(sf::Color::White); + pickButtonOlaf.setCharacterSize(55 ); + pickButtonOlaf.setPosition(sf::Vector2f(1250, 650)); + + sf::Texture ExitButton; + sf::Sprite ExitButtonImage; + ExitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png") ; + ExitButtonImage.setPosition(10, 10); + ExitButtonImage.setScale(2, 2); + ExitButtonImage.setTexture(ExitButton); + + int frameNum = 3; + float animationDuration = 1; + + sf::Time elapsedTime; + sf::Clock clock; + int counter = 0; + + while (window.isOpen()) { + + sf::Time deltaTime = clock.restart(); + elapsedTime += deltaTime; + float timeAsSecond = elapsedTime.asSeconds(); + int animFrame = static_cast((timeAsSecond/animationDuration)* static_cast(frameNum))% frameNum; + + dinoKiraSprite.setTextureRect(sf::IntRect(animFrame * 24,0,24,24)); + dinoKuroSprite.setTextureRect(sf::IntRect(animFrame * 24, 0, 24, 24)); + dinoMortSprite.setTextureRect(sf::IntRect(animFrame * 24, 0, 24, 24)); + dinoOlafSprite.setTextureRect(sf::IntRect(animFrame * 24, 0, 24, 24)); + + sf::Event Event; + + + window.clear(); + window.draw(sprite); + window.draw(ExitButtonImage); + + if (counter == 3) window.draw(readyButton); + else window.draw(text); + + if (player.pull.count("Kira") == 1) + { + window.draw(pickButtonKira); + window.draw(dinoKiraSprite); + window.draw(dinoKiraCharacteristics); + window.draw(kiraText); + } + + if (player.pull.count("Kuro") == 1) + { + window.draw(pickButtonKuro); + window.draw(dinoKuroSprite); + window.draw(dinoKuroCharacteristics); + window.draw(kuroText); + } + + if (player.pull.count("Mort") == 1) + { + window.draw(pickButtonMort); + window.draw(dinoMortSprite); + window.draw(dinoMortCharacteristics); + window.draw(mortText); + } + + if (player.pull.count("Olaf") == 1) + { + window.draw(pickButtonOlaf); + window.draw(dinoOlafSprite); + window.draw(dinoOlafCharacteristics); + window.draw(olafText); + } + + window.display(); + + while (window.pollEvent(Event)) + { + switch ( Event.type ) + { + case sf::Event::MouseMoved: + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window ); + sf::Vector2f mousePosF( static_cast( mousePos.x ), static_cast( mousePos.y ) ); + + if (pickButtonKira.getGlobalBounds().contains(mousePosF ) && pickButtonKira.getString() == "pick" ) + { + pickButtonKira.setFillColor(sf::Color::Green); + } + else + { + pickButtonKira.setFillColor(sf::Color::White); + } + + if (pickButtonKuro.getGlobalBounds().contains(mousePosF ) && pickButtonKuro.getString() == "pick") + { + pickButtonKuro.setFillColor(sf::Color::Green); + } + else + { + pickButtonKuro.setFillColor(sf::Color::White); + } + + if (pickButtonMort.getGlobalBounds().contains(mousePosF ) && pickButtonMort.getString() == "pick") + { + pickButtonMort.setFillColor(sf::Color::Green); + } + else + { + pickButtonMort.setFillColor(sf::Color::White); + } + + if (pickButtonOlaf.getGlobalBounds().contains(mousePosF ) && pickButtonOlaf.getString() == "pick") + { + pickButtonOlaf.setFillColor(sf::Color::Green); + } + else + { + pickButtonOlaf.setFillColor(sf::Color::White); + } + + if (readyButton.getGlobalBounds().contains(mousePosF )) + { + readyButton.setFillColor(sf::Color::Green); + } + else + { + readyButton.setFillColor(sf::Color::White); + } + break; + } + case sf::Event::MouseButtonPressed: + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window ); + sf::Vector2f mousePosF( static_cast( mousePos.x ), static_cast( mousePos.y ) ); + + //if exit button pressed + if ( ExitButtonImage.getGlobalBounds().contains(mousePosF ) ) + { + window.close(); + Main_Menu(); + } + if (pickButtonKira.getGlobalBounds().contains(mousePosF) && pickButtonKira.getString() == "pick" && counter < 3 ) + { + pickButtonKira.setString("picked"); + player.vecPull.push_back(Kira().name); + counter++; + } + if (pickButtonKuro.getGlobalBounds().contains(mousePosF) && pickButtonKuro.getString() == "pick" && counter < 3) + { + pickButtonKuro.setString("picked"); + player.vecPull.push_back(Kuro().name); + counter++; + } + if (pickButtonMort.getGlobalBounds().contains(mousePosF) && pickButtonMort.getString() == "pick" && counter < 3) + { + pickButtonMort.setString("picked"); + player.vecPull.push_back(Mort().name); + counter++; + } + if (pickButtonOlaf.getGlobalBounds().contains(mousePosF) && pickButtonOlaf.getString() == "pick"&& counter < 3) + { + pickButtonOlaf.setString("picked"); + player.vecPull.push_back(Olaf().name); + counter++; + } + if (readyButton.getGlobalBounds().contains(mousePosF)) + { + window.close(); + Battle(); + } + break; + } + } + } + } + +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/Dino.h b/sem2/AntonovVV/DINO WAR/Dino.h new file mode 100644 index 00000000..1781bbcd --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Dino.h @@ -0,0 +1,108 @@ +#ifndef HELLOSFML_DINO_H +#define HELLOSFML_DINO_H +#include + +enum Terrain { Plain, River, Mountain }; + +class Dino { +public: + int STRENGTH; + int DEXTERITY; + int INTELLIGENCE; + std::string ULTY; + float HP = 100; + std::string name; + int cost; +public: + virtual int damage(Terrain terrain) = 0; +}; + +class Kira : public Dino +{ +public: + int cost = 100; + Kira() { + STRENGTH = 10; + DEXTERITY = 15; + INTELLIGENCE = 10; + cost = 100; + HP = 100; + name = "Kira"; + } + int damage(Terrain terrain) { + return terrain == Terrain::Mountain ? + 2 * INTELLIGENCE : + terrain == Terrain::River ? + DEXTERITY : + STRENGTH; + } +}; + +class Kuro : public Dino +{ +public: + int cost = 100; + Kuro() { + STRENGTH = 10; + DEXTERITY = 10; + INTELLIGENCE = 15; + cost = 100; + HP = 100; + name = "Kuro"; + } + + int damage(Terrain terrain) { + return terrain == Terrain::River ? + 2 * DEXTERITY : + terrain == Terrain::Plain || terrain == Terrain::Mountain ? + DEXTERITY : + STRENGTH; + } + +}; + +class Mort : public Dino +{ +public: + int cost = 100; + Mort() { + + STRENGTH = 15; + DEXTERITY = 10; + INTELLIGENCE = 10; + cost = 100; + HP = 100; + name = "Mort"; + } + int damage(Terrain terrain) { + return terrain == Terrain::Plain ? + 2 * STRENGTH : + terrain == Terrain::River ? + DEXTERITY : + INTELLIGENCE; + } +}; + +class Olaf : public Dino +{ +public: + int cost = 100; + Olaf() { + + STRENGTH = 15; + DEXTERITY = 15; + INTELLIGENCE = 15; + cost = 100; + HP = 100; + name = "Olaf"; + } + int damage(Terrain terrain) { + return terrain == Terrain::Plain ? + 2 * STRENGTH : + terrain == Terrain::River ? + 2 * DEXTERITY : + 2 * INTELLIGENCE; + } +}; + +#endif //HELLOSFML_DINO_H diff --git a/sem2/AntonovVV/DINO WAR/ExitButton.png b/sem2/AntonovVV/DINO WAR/ExitButton.png new file mode 100644 index 00000000..c09859a7 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/ExitButton.png differ diff --git a/sem2/AntonovVV/DINO WAR/Gerhaus.ttf b/sem2/AntonovVV/DINO WAR/Gerhaus.ttf new file mode 100644 index 00000000..d4210b05 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Gerhaus.ttf differ diff --git a/sem2/AntonovVV/DINO WAR/Inventory.txt b/sem2/AntonovVV/DINO WAR/Inventory.txt new file mode 100644 index 00000000..93dc6d9c --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Inventory.txt @@ -0,0 +1,3 @@ +Kira +Kuro +Mort diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/avoid.png b/sem2/AntonovVV/DINO WAR/Kira/base/avoid.png new file mode 100644 index 00000000..a688764f Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/avoid.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/bite.png b/sem2/AntonovVV/DINO WAR/Kira/base/bite.png new file mode 100644 index 00000000..6d219928 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/bite.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/dash.png b/sem2/AntonovVV/DINO WAR/Kira/base/dash.png new file mode 100644 index 00000000..2bc01821 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/dash.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/dead.png b/sem2/AntonovVV/DINO WAR/Kira/base/dead.png new file mode 100644 index 00000000..d0515892 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/dead.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/hurt.png b/sem2/AntonovVV/DINO WAR/Kira/base/hurt.png new file mode 100644 index 00000000..a383bdd9 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/hurt.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/idle.png b/sem2/AntonovVV/DINO WAR/Kira/base/idle.png new file mode 100644 index 00000000..ba4d24c2 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/jump.png b/sem2/AntonovVV/DINO WAR/Kira/base/jump.png new file mode 100644 index 00000000..c2dea584 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/jump.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/kick.png b/sem2/AntonovVV/DINO WAR/Kira/base/kick.png new file mode 100644 index 00000000..75ae0102 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/kick.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/move.png b/sem2/AntonovVV/DINO WAR/Kira/base/move.png new file mode 100644 index 00000000..a55ac141 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/base/scan.png b/sem2/AntonovVV/DINO WAR/Kira/base/scan.png new file mode 100644 index 00000000..a370ed22 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/base/scan.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/egg/crack.png b/sem2/AntonovVV/DINO WAR/Kira/egg/crack.png new file mode 100644 index 00000000..a486c550 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/egg/crack.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/egg/hatch.png b/sem2/AntonovVV/DINO WAR/Kira/egg/hatch.png new file mode 100644 index 00000000..0a19272f Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/egg/hatch.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/egg/move.png b/sem2/AntonovVV/DINO WAR/Kira/egg/move.png new file mode 100644 index 00000000..b7d03435 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/egg/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/ghost/idle.png b/sem2/AntonovVV/DINO WAR/Kira/ghost/idle.png new file mode 100644 index 00000000..938f460c Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/ghost/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kira/ghost/move.png b/sem2/AntonovVV/DINO WAR/Kira/ghost/move.png new file mode 100644 index 00000000..621e0bde Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kira/ghost/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/avoid.png b/sem2/AntonovVV/DINO WAR/Kuro/base/avoid.png new file mode 100644 index 00000000..dfebba3a Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/avoid.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/bite.png b/sem2/AntonovVV/DINO WAR/Kuro/base/bite.png new file mode 100644 index 00000000..5afa7d60 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/bite.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/dash.png b/sem2/AntonovVV/DINO WAR/Kuro/base/dash.png new file mode 100644 index 00000000..39094654 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/dash.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/dead.png b/sem2/AntonovVV/DINO WAR/Kuro/base/dead.png new file mode 100644 index 00000000..9d958780 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/dead.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/hurt.png b/sem2/AntonovVV/DINO WAR/Kuro/base/hurt.png new file mode 100644 index 00000000..26dcad37 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/hurt.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/idle.png b/sem2/AntonovVV/DINO WAR/Kuro/base/idle.png new file mode 100644 index 00000000..b2a1929d Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/jump.png b/sem2/AntonovVV/DINO WAR/Kuro/base/jump.png new file mode 100644 index 00000000..42ce061d Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/jump.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/kick.png b/sem2/AntonovVV/DINO WAR/Kuro/base/kick.png new file mode 100644 index 00000000..0d78a72f Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/kick.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/move.png b/sem2/AntonovVV/DINO WAR/Kuro/base/move.png new file mode 100644 index 00000000..261b9dc3 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/base/scan.png b/sem2/AntonovVV/DINO WAR/Kuro/base/scan.png new file mode 100644 index 00000000..b86f2a05 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/base/scan.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/egg/crack.png b/sem2/AntonovVV/DINO WAR/Kuro/egg/crack.png new file mode 100644 index 00000000..bb13aedb Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/egg/crack.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/egg/hatch.png b/sem2/AntonovVV/DINO WAR/Kuro/egg/hatch.png new file mode 100644 index 00000000..1b51068e Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/egg/hatch.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/egg/move.png b/sem2/AntonovVV/DINO WAR/Kuro/egg/move.png new file mode 100644 index 00000000..c0dd3b73 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/egg/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/ghost/idle.png b/sem2/AntonovVV/DINO WAR/Kuro/ghost/idle.png new file mode 100644 index 00000000..00bbb031 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/ghost/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Kuro/ghost/move.png b/sem2/AntonovVV/DINO WAR/Kuro/ghost/move.png new file mode 100644 index 00000000..42db2c3e Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Kuro/ghost/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/LooserMenu.cpp b/sem2/AntonovVV/DINO WAR/LooserMenu.cpp new file mode 100644 index 00000000..09bcdcbb --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/LooserMenu.cpp @@ -0,0 +1,93 @@ +#include "AssetManager.hpp" +#include "Menu.h" +#include +#include +#include "Player.h" + +void Looser(){ + + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Texture background; + background.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg");; + sf::Sprite sprite(background); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + + sf::Text text("Dino Wars", font); + text.setCharacterSize(150); + text.setFillColor(sf::Color(sf :: Color :: White)); + text.setStyle(sf::Text::Bold); + sf::Vector2f centerPos = sf::Vector2f(window.getSize().x / 2, window.getSize().y / 2); + text.setPosition(centerPos.x - text.getGlobalBounds().width / 2 + 400,centerPos.y - text.getGlobalBounds().height / 2 - 400); + + sf::FloatRect textRect = text.getLocalBounds(); + text.setOrigin(textRect.width/2,textRect.height/2); + + sf::Text startText; + startText.setFont( font ); + startText.setStyle( sf::Text::Regular ); + startText.setString( "Wasted." ); + startText.setFillColor( sf::Color::Green); + startText.setCharacterSize(120); + startText.setPosition(700, 300); + + sf::Texture exitButton; + sf::Sprite exitButtonImage; + exitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png") ; + exitButtonImage.setPosition(10, 10); + exitButtonImage.setScale(2, 2); + exitButtonImage.setTexture(exitButton); + + sf::Texture ghost; + sf::Sprite ghostSprite; + ghost.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Olaf/ghost/idle.png"); + ghostSprite.setPosition(800, 450 ); + ghostSprite.setScale(sf::Vector2f(10.0f, 10.0f)); + ghostSprite.setTexture(ghost ); + + int frameNum = 3; + float animationDuration = 1; + sf::Time elapsedTime; + sf::Clock clock; + + while (window.isOpen()) { + + sf::Time deltaTime = clock.restart(); + elapsedTime += deltaTime; + float timeAsSecond = elapsedTime.asSeconds(); + + int animFrame = static_cast((timeAsSecond/animationDuration)* static_cast(frameNum))% frameNum; + + ghostSprite.setTextureRect(sf::IntRect(animFrame * 24,0,24,24)); + + window.clear(); + window.draw(sprite); + window.draw(startText); + window.draw(exitButtonImage); + window.draw(ghostSprite); + window.draw(text); + window.display(); + + sf::Event Event; + + while (window.pollEvent(Event)) { + switch (Event.type) { + + case sf::Event::MouseButtonPressed: + { + sf::Vector2i mousePos = sf::Mouse::getPosition( window ); + sf::Vector2f mousePosF( static_cast( mousePos.x ), static_cast( mousePos.y ) ); + + if ( exitButtonImage.getGlobalBounds().contains( mousePosF ) ) + { + window.close(); + Main_Menu(); + } + } + break; + } + } + } +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/MainMenu.cpp b/sem2/AntonovVV/DINO WAR/MainMenu.cpp new file mode 100644 index 00000000..5b2c408a --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/MainMenu.cpp @@ -0,0 +1,112 @@ +#include +#include +#include "Menu.h" + +void Main_Menu() { + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + sf::Text text; + text.setFont(font); + text.setString("DINO WARS"); + text.setCharacterSize(150); + text.setFillColor(sf::Color::White); + sf::Vector2f centerPos = sf::Vector2f(window.getSize().x / 2, window.getSize().y / 2); + text.setPosition(centerPos.x - text.getGlobalBounds().width / 2,centerPos.y - text.getGlobalBounds().height / 2 - 400); + + sf::Text Profile_button, Shop_button, Play_button; + Profile_button.setFont(font); + Shop_button.setFont(font); + Play_button.setFont(font); + + Profile_button.setString("Profile"); + Shop_button.setString("Shop"); + Play_button.setString("Play"); + Profile_button.setCharacterSize(75); + Shop_button.setCharacterSize(75); + Play_button.setCharacterSize(75); + + Profile_button.setFillColor(sf::Color::White); + Play_button.setFillColor(sf::Color::White); + Shop_button.setFillColor(sf::Color::White); + + Profile_button.setPosition(centerPos.x - Profile_button.getGlobalBounds().width / 2 - 450,centerPos.y - Profile_button.getGlobalBounds().height / 2 +360); + Shop_button.setPosition(centerPos.x - Shop_button.getGlobalBounds().width / 2 + 50,centerPos.y - Shop_button.getGlobalBounds().height / 2 + 360); + Play_button.setPosition(centerPos.x - Play_button.getGlobalBounds().width / 2 + 550,centerPos.y - Play_button.getGlobalBounds().height / 2 + 360); + + + sf::Texture img; + img.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + sf::Sprite sprite(img); + + sf::Texture exitButton; + exitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png"); + sf::Sprite exitButtonImage(exitButton); + exitButtonImage.setScale(2, 2); + exitButtonImage.setPosition(10, 10); + + + + while (window.isOpen()) { + sf::Event event; + window.clear(); + window.draw(sprite); + window.draw(text); + window.draw(exitButtonImage); + window.draw(Profile_button); + window.draw(Shop_button); + window.draw(Play_button); + window.display(); + + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); + } + switch (event.type) { + case sf::Event::KeyPressed : + event.key.code = sf::Keyboard::Escape; + window.close(); + break; + case sf::Event::MouseButtonPressed: { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + sf::Vector2f mousePosF(static_cast( mousePos.x ), static_cast( mousePos.y )); + if (exitButtonImage.getGlobalBounds().contains(mousePosF)) { + window.close(); + Start_Menu(); + } + if (Profile_button.getGlobalBounds().contains(mousePosF)) { + window.close(); + Profile_Menu(); + } + if (Shop_button.getGlobalBounds().contains(mousePosF)) { + window.close(); + Shop_Menu(); + } + if (Play_button.getGlobalBounds().contains(mousePosF)) { + window.close(); + Battle_Menu(); + } + } + case sf :: Event :: MouseMoved: { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + sf::Vector2f mousePosF(static_cast( mousePos.x ), static_cast( mousePos.y )); + if (Profile_button.getGlobalBounds().contains(mousePosF)) { + Profile_button.setFillColor(sf :: Color :: Green); + } + else Profile_button.setFillColor(sf :: Color :: White); + if (Shop_button.getGlobalBounds().contains(mousePosF)) { + Shop_button.setFillColor(sf :: Color :: Green); + } + else Shop_button.setFillColor(sf :: Color :: White); + if (Play_button.getGlobalBounds().contains(mousePosF)) { + Play_button.setFillColor(sf :: Color :: Green); + } + else Play_button.setFillColor(sf :: Color :: White); + + } + } + + } + } +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/Menu.h b/sem2/AntonovVV/DINO WAR/Menu.h new file mode 100644 index 00000000..13d8daab --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Menu.h @@ -0,0 +1,15 @@ +#ifndef HELLOSFML_MENU_H +#define HELLOSFML_MENU_H +#include +#include + +void Main_Menu(); +void Start_Menu(); +void Profile_Menu(); +void Shop_Menu(); +void Battle_Menu(); +void Battle(); +void Winner(); +void Looser(); + +#endif //HELLOSFML_MENU_H diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/avoid.png b/sem2/AntonovVV/DINO WAR/Mort/base/avoid.png new file mode 100644 index 00000000..d1b58e6e Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/avoid.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/bite.png b/sem2/AntonovVV/DINO WAR/Mort/base/bite.png new file mode 100644 index 00000000..4a70ba5b Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/bite.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/dash.png b/sem2/AntonovVV/DINO WAR/Mort/base/dash.png new file mode 100644 index 00000000..d02c1f39 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/dash.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/dead.png b/sem2/AntonovVV/DINO WAR/Mort/base/dead.png new file mode 100644 index 00000000..186af7fc Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/dead.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/hurt.png b/sem2/AntonovVV/DINO WAR/Mort/base/hurt.png new file mode 100644 index 00000000..0860041b Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/hurt.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/idle.png b/sem2/AntonovVV/DINO WAR/Mort/base/idle.png new file mode 100644 index 00000000..a1d34b11 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/jump.png b/sem2/AntonovVV/DINO WAR/Mort/base/jump.png new file mode 100644 index 00000000..ea1f490a Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/jump.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/kick.png b/sem2/AntonovVV/DINO WAR/Mort/base/kick.png new file mode 100644 index 00000000..1eadb802 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/kick.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/move.png b/sem2/AntonovVV/DINO WAR/Mort/base/move.png new file mode 100644 index 00000000..13c5e527 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/base/scan.png b/sem2/AntonovVV/DINO WAR/Mort/base/scan.png new file mode 100644 index 00000000..5d0614fb Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/base/scan.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/egg/crack.png b/sem2/AntonovVV/DINO WAR/Mort/egg/crack.png new file mode 100644 index 00000000..35465074 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/egg/crack.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/egg/hatch.png b/sem2/AntonovVV/DINO WAR/Mort/egg/hatch.png new file mode 100644 index 00000000..e157da40 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/egg/hatch.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/egg/move.png b/sem2/AntonovVV/DINO WAR/Mort/egg/move.png new file mode 100644 index 00000000..347bfc1c Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/egg/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/ghost/idle.png b/sem2/AntonovVV/DINO WAR/Mort/ghost/idle.png new file mode 100644 index 00000000..f873632f Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/ghost/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mort/ghost/move.png b/sem2/AntonovVV/DINO WAR/Mort/ghost/move.png new file mode 100644 index 00000000..41bc76cc Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mort/ghost/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Mountain.jpg b/sem2/AntonovVV/DINO WAR/Mountain.jpg new file mode 100644 index 00000000..10b90d04 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Mountain.jpg differ diff --git a/sem2/AntonovVV/DINO WAR/Nickname.txt b/sem2/AntonovVV/DINO WAR/Nickname.txt new file mode 100644 index 00000000..8b6b3781 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Nickname.txt @@ -0,0 +1 @@ +vovaant \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/avoid.png b/sem2/AntonovVV/DINO WAR/Olaf/base/avoid.png new file mode 100644 index 00000000..fe26bce3 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/avoid.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/bite.png b/sem2/AntonovVV/DINO WAR/Olaf/base/bite.png new file mode 100644 index 00000000..b37c5a40 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/bite.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/dash.png b/sem2/AntonovVV/DINO WAR/Olaf/base/dash.png new file mode 100644 index 00000000..265f5780 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/dash.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/dead.png b/sem2/AntonovVV/DINO WAR/Olaf/base/dead.png new file mode 100644 index 00000000..12772dab Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/dead.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/hurt.png b/sem2/AntonovVV/DINO WAR/Olaf/base/hurt.png new file mode 100644 index 00000000..ffb6f2c5 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/hurt.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/idle.png b/sem2/AntonovVV/DINO WAR/Olaf/base/idle.png new file mode 100644 index 00000000..a9c80796 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/jump.png b/sem2/AntonovVV/DINO WAR/Olaf/base/jump.png new file mode 100644 index 00000000..b96e347c Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/jump.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/kick.png b/sem2/AntonovVV/DINO WAR/Olaf/base/kick.png new file mode 100644 index 00000000..edd1b964 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/kick.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/move.png b/sem2/AntonovVV/DINO WAR/Olaf/base/move.png new file mode 100644 index 00000000..75479caa Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/base/scan.png b/sem2/AntonovVV/DINO WAR/Olaf/base/scan.png new file mode 100644 index 00000000..04a87340 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/base/scan.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/egg/crack.png b/sem2/AntonovVV/DINO WAR/Olaf/egg/crack.png new file mode 100644 index 00000000..84b96db8 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/egg/crack.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/egg/hatch.png b/sem2/AntonovVV/DINO WAR/Olaf/egg/hatch.png new file mode 100644 index 00000000..ccbe95bd Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/egg/hatch.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/egg/move.png b/sem2/AntonovVV/DINO WAR/Olaf/egg/move.png new file mode 100644 index 00000000..98560f07 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/egg/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/ghost/idle.png b/sem2/AntonovVV/DINO WAR/Olaf/ghost/idle.png new file mode 100644 index 00000000..e95e7aca Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/ghost/idle.png differ diff --git a/sem2/AntonovVV/DINO WAR/Olaf/ghost/move.png b/sem2/AntonovVV/DINO WAR/Olaf/ghost/move.png new file mode 100644 index 00000000..f0c6d1e9 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/Olaf/ghost/move.png differ diff --git a/sem2/AntonovVV/DINO WAR/Player.h b/sem2/AntonovVV/DINO WAR/Player.h new file mode 100644 index 00000000..b12ad8e0 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Player.h @@ -0,0 +1,17 @@ +#ifndef HELLOSFML_PLAYER_H +#define HELLOSFML_PLAYER_H +#include + +class Player { +public: + std :: string nickname; + int balance = 300; + std :: set pull; + std :: vector vecPull; +}; +class Enemy : public Player +{ +}; +inline Player player; + +#endif //HELLOSFML_PLAYER_H diff --git a/sem2/AntonovVV/DINO WAR/ProfileMenu.cpp b/sem2/AntonovVV/DINO WAR/ProfileMenu.cpp new file mode 100644 index 00000000..2477a316 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/ProfileMenu.cpp @@ -0,0 +1,98 @@ +#include "Menu.h" +#include +#include +#include "Textbox.hpp" +#include "Player.h" + +void Profile_Menu() { + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + sf::Text text; + text.setFont(font); + text.setString("DINO WARS"); + text.setCharacterSize(150); + text.setFillColor(sf::Color::White); + sf::Vector2f centerPos = sf::Vector2f(window.getSize().x / 2, window.getSize().y / 2); + text.setPosition(centerPos.x - text.getGlobalBounds().width / 2,centerPos.y - text.getGlobalBounds().height / 2 - 400); + + sf::Text enter_text, success; + + enter_text.setFont(font); + success.setFont(font); + + enter_text.setString("Enter your nickname:"); + success.setString("Success!"); + enter_text.setCharacterSize(75); + success.setCharacterSize(100); + + enter_text.setFillColor(sf::Color::White); + success.setFillColor(sf::Color::White); + + enter_text.setPosition(centerPos.x - enter_text.getGlobalBounds().width / 2 - 500,centerPos.y - enter_text.getGlobalBounds().height / 2 + 360); + success.setPosition(centerPos.x - success.getGlobalBounds().width / 2 - 250,centerPos.y - success.getGlobalBounds().height / 2 + 360); + + + sf::Texture img; + img.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + sf::Sprite sprite(img); + + sf::Texture exitButton; + exitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png"); + sf::Sprite exitButtonImage(exitButton); + exitButtonImage.setScale(2, 2); + exitButtonImage.setPosition(10, 10); + + Textbox textbox(window, font); + textbox.setDimensons(1000, 870, 600, 100); + textbox.setFocus(true); + sf::Text title; + + bool success_flag = false; + + + std::ofstream file("C:/Users/Asus/CLionProjects/HelloSFML/Nickname.txt"); + while (window.isOpen()) { + sf::Event event; + window.clear(); + window.draw(sprite); + window.draw(text); + window.draw(exitButtonImage); + if (success_flag == true) window.draw(success); + else window.draw(enter_text); + textbox.draw(); + window.display(); + + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); + } + switch (event.type) { + + case sf::Event::MouseButtonPressed: { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + sf::Vector2f mousePosF(static_cast( mousePos.x ), static_cast( mousePos.y )); + if (exitButtonImage.getGlobalBounds().contains(mousePosF)) { + window.close(); + Main_Menu(); + } + } + + } + + std::string enteringText = textbox.getString(); + if (!success_flag) { + textbox.pollEvent(event); + } + + if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Enter)) + { + player.nickname = enteringText; + file << enteringText; + success_flag = true; + file.close(); + } + } + } +} diff --git a/sem2/AntonovVV/DINO WAR/River.jpg b/sem2/AntonovVV/DINO WAR/River.jpg new file mode 100644 index 00000000..42628c05 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/River.jpg differ diff --git a/sem2/AntonovVV/DINO WAR/ShopMenu.cpp b/sem2/AntonovVV/DINO WAR/ShopMenu.cpp new file mode 100644 index 00000000..6cfb362c --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/ShopMenu.cpp @@ -0,0 +1,282 @@ +#include "Menu.h" +#include +#include +#include "Dino.h" +#include "Player.h" + +void Shop_Menu() +{ + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + + sf::Texture img; + img.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + sf::Sprite sprite(img); + + sf::Text kiraText; + kiraText.setString("Kira"); + kiraText.setFont(font); + kiraText.setFillColor(sf::Color::Green); + kiraText.setCharacterSize(40); + kiraText.setPosition(710,80); + + sf::Text kuroText; + kuroText.setString("Kuro"); + kuroText.setFont(font); + kuroText.setFillColor(sf::Color::Green); + kuroText.setCharacterSize(40); + kuroText.setPosition(710,250); + + sf::Text mortText; + mortText.setString("Mort"); + mortText.setFont(font); + mortText.setFillColor(sf::Color::Green); + mortText.setCharacterSize(40); + mortText.setPosition(710,420); + + sf::Text olafText; + olafText.setString("Olaf"); + olafText.setFont(font); + olafText.setFillColor(sf::Color::Green); + olafText.setCharacterSize(40); + olafText.setPosition(710,590); + + sf::Texture dinoKiraTexture; + dinoKiraTexture.loadFromFile( "C:/Users/Asus/CLionProjects/HelloSFML/kira/base/idle.png"); + sf::Sprite dinoKiraSprite(dinoKiraTexture,sf::IntRect(0,0,24,24)); + dinoKiraSprite.setPosition(650, 100); + dinoKiraSprite.setScale(sf::Vector2f(7.0f,7.0f)); + + sf::Texture dinoKuroTexture; + dinoKuroTexture.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/kuro/base/idle.png" ); + sf::Sprite dinoKuroSprite(dinoKuroTexture, sf::IntRect(0, 0, 24, 24)); + dinoKuroSprite.setPosition(650, 270); + dinoKuroSprite.setScale(sf::Vector2f(7.0f, 7.0f)); + + sf::Texture dinoMortTexture; + dinoMortTexture.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/mort/base/idle.png" ); + sf::Sprite dinoMortSprite(dinoMortTexture, sf::IntRect(0, 0, 24, 24)); + dinoMortSprite.setPosition(650, 440); + dinoMortSprite.setScale(sf::Vector2f(7.0f, 7.0f)); + + sf::Texture dinoOlafTexture; + dinoOlafTexture.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/olaf/base/idle.png" ); + sf::Sprite dinoOlafSprite(dinoOlafTexture, sf::IntRect(0, 0, 24, 24)); + dinoOlafSprite.setPosition(650, 610); + dinoOlafSprite.setScale(sf::Vector2f(7.0f,7.0f)); + + + sf::Text dinoKiraCharacteristics("Strength - " + std::to_string(Kira().STRENGTH) + "\nDexteriry - " + std::to_string(Kira().DEXTERITY) + "\nIntelegience - " + std::to_string(Kira().INTELLIGENCE), font, 40); + dinoKiraCharacteristics.setFillColor(sf::Color::White); + dinoKiraCharacteristics.setStyle(sf::Text::Bold); + dinoKiraCharacteristics.setPosition(sf::Vector2f(850,115)); + + sf::Text dinoKuroCharacteristics("Strength - " + std::to_string(Kuro().STRENGTH) + "\nDexteriry - " + std::to_string(Kuro().DEXTERITY) + "\nIntelegience - " + std::to_string(Kuro().INTELLIGENCE), font, 40); + dinoKuroCharacteristics.setFillColor(sf::Color::White); + dinoKuroCharacteristics.setStyle(sf::Text::Bold); + dinoKuroCharacteristics.setPosition(sf::Vector2f(850, 285)); + + sf::Text dinoMortCharacteristics("Strength - " + std::to_string(Mort().STRENGTH) + "\nDexteriry - " + std::to_string(Mort().DEXTERITY) + "\nIntelegience - " + std::to_string(Mort().INTELLIGENCE), font, 40); + dinoMortCharacteristics.setFillColor(sf::Color::White); + dinoMortCharacteristics.setStyle(sf::Text::Bold); + dinoMortCharacteristics.setPosition(sf::Vector2f(850, 455)); + + sf::Text dinoOlafCharacteristics("Strength - " + std::to_string(Olaf().STRENGTH) + "\nDexteriry - " + std::to_string(Olaf().DEXTERITY) + "\nIntelegience - " + std::to_string(Olaf().INTELLIGENCE), font, 40); + dinoOlafCharacteristics.setFillColor(sf::Color::White); + dinoOlafCharacteristics.setStyle(sf::Text::Bold); + dinoOlafCharacteristics.setPosition(sf::Vector2f(850, 625)); + + + sf::Text BuyButtonKira; + BuyButtonKira.setFont(font ); + BuyButtonKira.setStyle(sf::Text::Regular ); + if (player.pull.count("Kira") == 1) BuyButtonKira.setString("Purchased"); + else BuyButtonKira.setString("BUY"); + BuyButtonKira.setFillColor(sf::Color::White); + BuyButtonKira.setCharacterSize(55 ); + BuyButtonKira.setPosition(sf::Vector2f(1250, 145)); + + sf::Text BuyButtonKuro; + BuyButtonKuro.setFont(font ); + BuyButtonKuro.setStyle(sf::Text::Regular ); + if (player.pull.count("Kuro") == 1) BuyButtonKuro.setString("Purchased"); + else BuyButtonKuro.setString("BUY"); + BuyButtonKuro.setFillColor(sf::Color::White ); + BuyButtonKuro.setCharacterSize(55 ); + BuyButtonKuro.setPosition(sf::Vector2f(1250, 290)); + + sf::Text BuyButtonMort; + BuyButtonMort.setFont(font ); + BuyButtonMort.setStyle(sf::Text::Regular ); + if (player.pull.count("Mort") == 1) BuyButtonMort.setString("Purchased"); + else BuyButtonMort.setString("BUY"); + BuyButtonMort.setFillColor(sf::Color::White ); + BuyButtonMort.setCharacterSize(55 ); + BuyButtonMort.setPosition(sf::Vector2f(1250, 470)); + + sf::Text BuyButtonOlaf; + BuyButtonOlaf.setFont(font ); + BuyButtonOlaf.setStyle(sf::Text::Regular ); + if (player.pull.count("Olaf")) BuyButtonOlaf.setString("Purchased"); + else BuyButtonOlaf.setString("BUY"); + BuyButtonOlaf.setFillColor(sf::Color::White); + BuyButtonOlaf.setCharacterSize(55 ); + BuyButtonOlaf.setPosition(sf::Vector2f(1250, 650)); + + sf::Texture ExitButton; + sf::Sprite ExitButtonImage; + ExitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png") ; + ExitButtonImage.setPosition(10, 10); + ExitButtonImage.setScale(2, 2); + ExitButtonImage.setTexture(ExitButton); + + int frameNum = 3; + float animationDuration = 1; + + sf::Time elapsedTime; + sf::Clock clock; + + + std:: ofstream file("C:/Users/Asus/CLionProjects/HelloSFML/Inventory.txt"); + + while (window.isOpen()) { + + sf::Time deltaTime = clock.restart(); + elapsedTime += deltaTime; + float timeAsSecond = elapsedTime.asSeconds(); + + int animFrame = static_cast((timeAsSecond/animationDuration)* static_cast(frameNum))% frameNum; + + dinoKiraSprite.setTextureRect(sf::IntRect(animFrame * 24,0,24,24)); + dinoKuroSprite.setTextureRect(sf::IntRect(animFrame * 24, 0, 24, 24)); + dinoMortSprite.setTextureRect(sf::IntRect(animFrame * 24, 0, 24, 24)); + dinoOlafSprite.setTextureRect(sf::IntRect(animFrame * 24, 0, 24, 24)); + + sf::Event Event; + + + window.clear(); + window.draw(sprite); + + sf::Text balanceText("Balance: " + std :: to_string(player.balance) + "$", font, 30); + balanceText.setFillColor(sf::Color :: Green); + balanceText.setStyle(sf::Text::Bold); + balanceText.setPosition(sf::Vector2f(800,40)); + + window.draw(BuyButtonKira); + window.draw(BuyButtonKuro); + window.draw(BuyButtonMort); + window.draw(BuyButtonOlaf); + + window.draw(dinoKiraSprite); + window.draw(dinoKuroSprite); + window.draw(dinoMortSprite); + window.draw(dinoOlafSprite); + window.draw(ExitButtonImage); + + window.draw(dinoKiraCharacteristics); + window.draw(dinoKuroCharacteristics); + window.draw(dinoMortCharacteristics); + window.draw(dinoOlafCharacteristics); + window.draw(balanceText); + window.draw(kiraText); + window.draw(kuroText); + window.draw(mortText); + window.draw(olafText); + + window.display(); + + while (window.pollEvent(Event)) + { + switch ( Event.type ) + { + case sf::Event::MouseMoved: + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window ); + sf::Vector2f mousePosF( static_cast( mousePos.x ), static_cast( mousePos.y ) ); + + if (BuyButtonKira.getGlobalBounds().contains(mousePosF ) && BuyButtonKira.getString() == "BUY" ) + { + BuyButtonKira.setFillColor(sf::Color::Green); + } + else + { + BuyButtonKira.setFillColor(sf::Color::White); + } + + if (BuyButtonKuro.getGlobalBounds().contains(mousePosF ) && BuyButtonKuro.getString() == "BUY") + { + BuyButtonKuro.setFillColor(sf::Color::Green); + } + else + { + BuyButtonKuro.setFillColor(sf::Color::White); + } + + if (BuyButtonMort.getGlobalBounds().contains(mousePosF ) && BuyButtonMort.getString() == "BUY") + { + BuyButtonMort.setFillColor(sf::Color::Green); + } + else + { + BuyButtonMort.setFillColor(sf::Color::White); + } + + if (BuyButtonOlaf.getGlobalBounds().contains(mousePosF ) && BuyButtonOlaf.getString() == "BUY") + { + BuyButtonOlaf.setFillColor(sf::Color::Green); + } + else + { + BuyButtonOlaf.setFillColor(sf::Color::White); + } + + break; + } + case sf::Event::MouseButtonPressed: + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window ); + sf::Vector2f mousePosF( static_cast( mousePos.x ), static_cast( mousePos.y ) ); + + //if exit button pressed + if ( ExitButtonImage.getGlobalBounds().contains(mousePosF ) ) + { + window.close(); + Main_Menu(); + } + if (BuyButtonKira.getGlobalBounds().contains(mousePosF) && BuyButtonKira.getString() == "BUY" && player.balance > 0) + { + player.balance -= 100; + BuyButtonKira.setString("Purchased"); + file << Kira().name << "\n"; + player.pull.insert(Kira().name); + } + if (BuyButtonKuro.getGlobalBounds().contains(mousePosF) && BuyButtonKuro.getString() == "BUY" && player.balance > 0) + { + player.balance -= 100; + BuyButtonKuro.setString("Purchased"); + file << Kuro().name << "\n"; + player.pull.insert(Kuro().name); + } + if (BuyButtonMort.getGlobalBounds().contains(mousePosF) && BuyButtonMort.getString() == "BUY" && player.balance > 0) + { + player.balance -= 100; + BuyButtonMort.setString("Purchased"); + file << Mort().name << "\n"; + player.pull.insert(Mort().name); + } + if (BuyButtonOlaf.getGlobalBounds().contains(mousePosF) && BuyButtonOlaf.getString() == "BUY" && player.balance > 0) + { + player.balance -= 100; + BuyButtonOlaf.setString("Purchased"); + file << Olaf().name << "\n"; + player.pull.insert(Olaf().name); + } + break; + } + } + } + } +} diff --git a/sem2/AntonovVV/DINO WAR/StartButton.png b/sem2/AntonovVV/DINO WAR/StartButton.png new file mode 100644 index 00000000..536afae5 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/StartButton.png differ diff --git a/sem2/AntonovVV/DINO WAR/StartMenu.cpp b/sem2/AntonovVV/DINO WAR/StartMenu.cpp new file mode 100644 index 00000000..1da5f94b --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/StartMenu.cpp @@ -0,0 +1,67 @@ +#include "Menu.h" +#include +#include + +void Start_Menu() { + + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + sf::Text text; + text.setFont(font); + text.setString("DINO WARS"); + text.setCharacterSize(150); + text.setFillColor(sf::Color::White); + sf::Vector2f centerPos = sf::Vector2f(window.getSize().x / 2, window.getSize().y / 2); + text.setPosition(centerPos.x - text.getGlobalBounds().width / 2, centerPos.y - text.getGlobalBounds().height / 2 - 450); + + sf::Texture img; + img.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + sf::Sprite sprite(img); + + sf::Texture exitButton; + exitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png"); + sf::Sprite exitButtonImage(exitButton); + exitButtonImage.setScale(2, 2); + exitButtonImage.setPosition(10, 10); + + sf::Texture startButton; + startButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/StartButton.png"); + sf::Sprite startButtonImage(startButton); + startButtonImage.setPosition(centerPos.x - startButtonImage.getGlobalBounds().width / 2 - 100, centerPos.y - startButtonImage.getGlobalBounds().height / 2 + 360); + startButtonImage.setScale(2.5, 2.5); + + while (window.isOpen()) { + sf::Event event; + window.clear(); + window.draw(sprite); + window.draw(text); + window.draw(exitButtonImage); + window.draw(startButtonImage); + window.display(); + + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); + } + switch (event.type) { + case sf::Event::KeyPressed : + event.key.code = sf::Keyboard::Escape; + window.close(); + break; + case sf::Event::MouseButtonPressed: { + sf::Vector2i mousePos = sf::Mouse::getPosition(window); + sf::Vector2f mousePosF(static_cast( mousePos.x ), static_cast( mousePos.y )); + if (exitButtonImage.getGlobalBounds().contains(mousePosF)) { + window.close(); + } + if (startButtonImage.getGlobalBounds().contains(mousePosF)) { + window.close(); + Main_Menu(); + } + } + } + } + } +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/Textbox.cpp b/sem2/AntonovVV/DINO WAR/Textbox.cpp new file mode 100644 index 00000000..2098caf1 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Textbox.cpp @@ -0,0 +1,67 @@ + +#include "Textbox.hpp" + +/********** -------------- **********/ +/********** Public Methods **********/ +/********** -------------- **********/ + + +Textbox::Textbox(sf::RenderWindow &windowToUse, sf::Font &fontToUse) : window(windowToUse), font(fontToUse) { + text = sf::Text("", font); + background.setFillColor(sf::Color::White); + text.setFillColor(sf::Color::Green); + text.setCharacterSize(65); +} + +void Textbox::draw() { + window.draw(background); + window.draw(text); +} + +void Textbox::setDimensons(double newX, double newY, double newWidth, double newHeight) { + x = newX; + y = newY; + width = newWidth; + height = newHeight; + text.setPosition(x, y-height/30); + background.setPosition(x, y); + background.setSize(sf::Vector2f(width, height)); +} + +void Textbox::setString(std::string newString) { + string = newString; + text.setString(string); +} + +std::string Textbox:: getString() { + return string; +} + +bool Textbox::pollEvent(sf::Event event) { + if(isFocused) { + if(event.type == sf::Event::TextEntered) + return enterText(event.text.unicode); + } + return false; +} + +void Textbox::setFocus(bool newFocus) { + isFocused = newFocus; +} + +/********** --------------- **********/ +/********** Private Methods **********/ +/********** --------------- **********/ + +bool Textbox::enterText(sf::Uint32 unicode) { + if(unicode == 8) + string = string.substr(0, string.length()-1); // delete key + else if(unicode == 10) + return true; // return key + else + string += (char) unicode; + text.setString(string); + return false; +} + + diff --git a/sem2/AntonovVV/DINO WAR/Textbox.hpp b/sem2/AntonovVV/DINO WAR/Textbox.hpp new file mode 100644 index 00000000..9fadaa19 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/Textbox.hpp @@ -0,0 +1,33 @@ +#ifndef Textbox_cpp +#define Textbox_cpp + +#include +#include +#include + +class Textbox { +public: + Textbox(sf::RenderWindow &windowToUse, sf::Font &fontToUse); + void setDimensons(double newX, double newY, double newWidth, double newHeight); + void draw(); + void setString(std::string newString); + std::string getString(); + bool pollEvent(sf::Event event); + void setFocus(bool newFocus); + void setReturnEvent(void (*newFunctionToCall)()); +private: + bool isFocused; + double x; + double y; + double width; + double height; + std::string string = ""; + sf::Font &font; + sf::RenderWindow &window; + sf::RectangleShape background; + sf::Text text; + + bool enterText(sf::Uint32 unicode); +}; + +#endif /* Textbox_cpp */ diff --git a/sem2/AntonovVV/DINO WAR/WinnerMenu.cpp b/sem2/AntonovVV/DINO WAR/WinnerMenu.cpp new file mode 100644 index 00000000..9dab7cfd --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/WinnerMenu.cpp @@ -0,0 +1,84 @@ +#include "AssetManager.hpp" +#include "Menu.h" +#include +#include +#include "Player.h" + +void Winner(){ + + sf::RenderWindow window(sf::VideoMode(1920, 1080), "DINO WARS", sf::Style::Fullscreen); + + sf::Texture background; + background.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/popa.jpg"); + sf::Sprite sprite(background); + + sf::Font font; + font.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/Gerhaus.ttf"); + + sf::Text text("Dino Wars", font); + text.setCharacterSize(150); + text.setFillColor(sf::Color(sf :: Color :: White)); + text.setStyle(sf::Text::Bold); + sf::Vector2f centerPos = sf::Vector2f(window.getSize().x / 2, window.getSize().y / 2); + text.setPosition(centerPos.x - text.getGlobalBounds().width / 2 + 400,centerPos.y - text.getGlobalBounds().height / 2 - 400); + + sf::FloatRect textRect = text.getLocalBounds(); + text.setOrigin(textRect.width/2,textRect.height/2); + + sf::Text startText; + startText.setFont(font); + startText.setStyle( sf::Text::Regular ); + startText.setString( "You win!\n\nFatality." ); + startText.setPosition(750, 300); + startText.setFillColor( sf::Color::Green); + startText.setCharacterSize(120); + + sf::Text balanceText; + balanceText.setFont(font); + balanceText.setCharacterSize(50); + balanceText.setFillColor(sf::Color::White); + balanceText.setStyle(sf::Text::Bold); + balanceText.setPosition(850, 900); + balanceText.setString("Reward: 50$"); + + sf::Texture exitButton; + sf::Sprite exitButtonImage; + exitButton.loadFromFile("C:/Users/Asus/CLionProjects/HelloSFML/ExitButton.png") ; + exitButtonImage.setPosition(10, 10); + exitButtonImage.setScale(2, 2); + exitButtonImage.setTexture(exitButton); + + exitButtonImage.setTexture( exitButton ); + + while (window.isOpen()) { + + window.clear(); + window.draw(sprite); + window.draw(startText); + window.draw(exitButtonImage); + window.draw(text); + window.draw(balanceText); + window.display(); + + sf::Event Event; + + while (window.pollEvent(Event)) { + switch (Event.type) { + + case sf::Event::MouseButtonPressed: + { + sf::Vector2i mousePos = sf::Mouse::getPosition(window ); + sf::Vector2f mousePosF( static_cast( mousePos.x ), static_cast( mousePos.y ) ); + + if ( exitButtonImage.getGlobalBounds().contains( mousePosF ) ) + { + window.close(); + player.balance += 50; + Main_Menu(); + } + } + break; + } + } + } +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/greenbar.png b/sem2/AntonovVV/DINO WAR/greenbar.png new file mode 100644 index 00000000..4402aba4 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/greenbar.png differ diff --git a/sem2/AntonovVV/DINO WAR/greenbarUpper.png b/sem2/AntonovVV/DINO WAR/greenbarUpper.png new file mode 100644 index 00000000..dbc9f766 Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/greenbarUpper.png differ diff --git a/sem2/AntonovVV/DINO WAR/main.cpp b/sem2/AntonovVV/DINO WAR/main.cpp new file mode 100644 index 00000000..ee983d30 --- /dev/null +++ b/sem2/AntonovVV/DINO WAR/main.cpp @@ -0,0 +1,8 @@ +#include "Menu.h" +#include + +int main() +{ + Start_Menu(); + return 0; +} \ No newline at end of file diff --git a/sem2/AntonovVV/DINO WAR/popa.jpg b/sem2/AntonovVV/DINO WAR/popa.jpg new file mode 100644 index 00000000..83d8abad Binary files /dev/null and b/sem2/AntonovVV/DINO WAR/popa.jpg differ