From e6954f8b8ed0add605421f58e0bc7784533d3884 Mon Sep 17 00:00:00 2001 From: Romanova Sofya Date: Tue, 8 Apr 2025 23:54:23 +0300 Subject: [PATCH 1/4] =?UTF-8?q?Create=20=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\320\276\320\272\321\203\320\274\320\265\320\275\321\202.txt" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\320\235\320\276\320\262\321\213\320\271 \321\202\320\265\320\272\321\201\321\202\320\276\320\262\321\213\320\271 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202.txt" diff --git "a/\320\235\320\276\320\262\321\213\320\271 \321\202\320\265\320\272\321\201\321\202\320\276\320\262\321\213\320\271 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202.txt" "b/\320\235\320\276\320\262\321\213\320\271 \321\202\320\265\320\272\321\201\321\202\320\276\320\262\321\213\320\271 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202.txt" new file mode 100644 index 00000000..e69de29b From 300a837db4059c97571e525b30481c190f307e2d Mon Sep 17 00:00:00 2001 From: Romanova Sofya Date: Tue, 8 Apr 2025 23:57:09 +0300 Subject: [PATCH 2/4] Romanova Sofya 2 sem --- enemy.png | Bin 0 -> 1763 bytes miniHW_2.cpp | 235 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 enemy.png create mode 100644 miniHW_2.cpp diff --git a/enemy.png b/enemy.png new file mode 100644 index 0000000000000000000000000000000000000000..514af0d5c30038bb1116a42ffe3299902d6805ae GIT binary patch literal 1763 zcmV<91|0c`P)Px#1ZP1_K>z@;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CJ8H1WvQ3gk%-kG<)S;nZtu< z%mQ{PKNZXP{0T7;hIRCYY}U*?tO~Vi!U8;`*A=RiXv_{%RX!pjB0fI8v$In!m!oSu zw^T}rCBI9jEme=49~wBUkV(m$m{Z)`+;lpfo+c?NNgxnl!;FZGjJ$N|Qht8^jT<*& zVq(xc1G2KRn3x#IJ4;MV#J1_Mb?ergoE#j5rm?XR+h#yvVIdh}IQ6vR-FQ{rRc1sI zTxx16`Ewl|jqGa1ShZ@^!Gj0O%gdP`8d6hJgPn}S@%Q&{Zf-`)fQ*ccn04#>f@;^jJ z&-8GcoSaOatZ(Bcsn<))M|GWgf3rccbKl_SUz7C0dl<)PISmU7D=I3|K5iY@u}9n5 z#yH6fv-)^9FK9JmP7RqUGMTPdrtj_5NoAnX=rtN`UA^k^6}^Hw6J&e1>?|!|`WnMj zmCw!1-LhqiwyC9m$8KGF2YLZ`VH*UIn|T{v2Z2EQcfICbnO-I*x72lYlLyds_h3IG zB=^h7u>cJtm5=s59YH6f}p6KY8+G zY-}viqt&$|zx=BD<4>l^C>#z~B;<(2TxT)Y#Toc~4v$y&tnX-6=9MQMN^;g<0js4t zAt7Pcu3e#_)T|``raJ$+I{%us^9eapaYQ0s@EVIHi#Yc7WbbC->%;Z-Vt&O?Sy`Eq zl9HA-@qA$#R$(y&1_p+Ngaii%OC%C+Z*Q?!Y-eYOZIftdXecNsAcZt9FArVQVH#mg zhR5Rxg+eDMCsJLlX~-F-udlDEsY$7PF>Cfb^ZXwG_!n~yxvr(sTqFPh002ovPDHLk FV1iOcMauvH literal 0 HcmV?d00001 diff --git a/miniHW_2.cpp b/miniHW_2.cpp new file mode 100644 index 00000000..bf168ab6 --- /dev/null +++ b/miniHW_2.cpp @@ -0,0 +1,235 @@ +// miniHW_2.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. +// + +#include +#include +#include +#include + +// (V) 1. M x N двумерное поле с тайлами(в примере 10 x 10) +// (V) 2. Скрытые тайлы -> открытые с эвентами +// (X) 3. эвенты должны отображаться, + Логика +// (X) 4. Под каждым тайлом с вероятность в 10% есть консервы, +// при вскрытии тайла -> восст. сытость +// (V) 5. Открыть M x N тайлов (все тайлы) для победы +// (V) 6. Экран победы + экран поражения +// (V) 7. За каждое открытие тайла теряем 1 сытость. Сытость равно 0, +// тогда поражение, + отображать сытость +// (V) 8. Начальное значени сытости - 25 + +#define CELLSIZE_M 10 +#define CELLSIZE_N 10 + +#define CHANCE_FOOD 10 +#define CHANCE_ENEMY 10 + +#define ENERGY_MAX 50 +#define HP_MAX 100 + +#define CELLSIZE_SCREEN 100.f + +enum CellType { + Type_enemy, + Type_Grass, + Type_Hill, + Type_Forest, + Type_Stone, + Type_Sand, + Type_Snow, + Type_Water, + Type_End +}; +enum TextureType { + Texture_Enemy, + Texture_Grass, + Texture_Hill, + Texture_Forest, + Texture_Stone, + Texture_Sand, + Texture_Snow, + Texture_Water, + Texture_Hide, + Texture_Soup, + Texture_End +}; + +struct Cell { + bool isEnemy; + bool isHidden; + bool isFood; + CellType cellType; +}; + +bool isWinOfGame(const Cell cells[CELLSIZE_M][CELLSIZE_N]) { + bool winCondition = true; + for (int x = 0; x < CELLSIZE_M; x++) { + for (int y = 0; y < CELLSIZE_N; y++) { + if (cells[x][y].isHidden) { + winCondition = false; + break; + } + } + } + return winCondition; +} + +bool isLoseOfGame(const int& energy, const int& hp) { + if (energy <= 0 or hp <= 0) { + return true; + } + return false; +} + +void clickTile(int& energy,int& hp, + const sf::Vector2i& mouseCoord, + Cell cells[CELLSIZE_M][CELLSIZE_N], + sf::RectangleShape shapes[CELLSIZE_M][CELLSIZE_N], + sf::Texture textures[TextureType::Texture_End]) { + + const int x = mouseCoord.x < 0 ? + 0 : + mouseCoord.x > CELLSIZE_SCREEN * CELLSIZE_M ? + CELLSIZE_M : + mouseCoord.x / CELLSIZE_SCREEN; + + const int y = mouseCoord.y < 0 ? + 0 : + mouseCoord.y > CELLSIZE_SCREEN * CELLSIZE_N ? + CELLSIZE_N : + mouseCoord.y / CELLSIZE_SCREEN; + + cells[x][y].isHidden = false; + + if (cells[x][y].isFood) { + shapes[x][y].setTexture(&textures[TextureType::Texture_Soup]); + energy = ENERGY_MAX; + } + else if (cells[x][y].isEnemy) { + shapes[x][y].setTexture(&textures[TextureType::Texture_Enemy]); + hp -= 10; + } + else + shapes[x][y].setTexture(&textures[cells[x][y].cellType]); +} + +int main() { + int energy = ENERGY_MAX; + int hp = HP_MAX; + + srand(time(0)); + + Cell cells[CELLSIZE_M][CELLSIZE_N]; + for (int x = 0; x < CELLSIZE_M; x++) { + for (int y = 0; y < CELLSIZE_N; y++) { + cells[x][y].isHidden = true; + cells[x][y].isFood = rand() % 100 < CHANCE_FOOD; + cells[x][y].isEnemy = rand() % 100 < CHANCE_ENEMY; + cells[x][y].cellType = static_cast + (rand() % (CellType::Type_End - 1)); + } + } + + sf::RenderWindow window( + sf::VideoMode({ static_cast (CELLSIZE_SCREEN * CELLSIZE_M), + static_cast (CELLSIZE_SCREEN * CELLSIZE_N) }), + "NOT MINESWEEPER GAME", sf::State::Windowed); + sf::Vector2i mouseCoord; + + sf::Font font("arial.ttf"); + sf::Text textEnergy(font); + sf::Text textCondition(font); + sf::Text textHp(font); + textEnergy.setCharacterSize(CELLSIZE_SCREEN / 2); + textEnergy.setFillColor(sf::Color::Red); + textEnergy.setStyle(sf::Text::Bold | sf::Text::Underlined); + textCondition.setCharacterSize(CELLSIZE_SCREEN); + textCondition.setFillColor(sf::Color::Red); + textCondition.setStyle(sf::Text::Bold | sf::Text::Underlined); + textHp.setCharacterSize(CELLSIZE_SCREEN / 2); + textHp.setStyle(sf::Text::Bold | sf::Text::Underlined); + textHp.setFillColor(sf::Color::Green); + sf::RectangleShape shapes[CELLSIZE_M][CELLSIZE_N]; + sf::Texture textures[TextureType::Texture_End]; + textures[TextureType::Texture_Enemy] = sf::Texture("enemy.png"); + textures[TextureType::Texture_Grass] = sf::Texture("grass.png"); + textures[TextureType::Texture_Hill] = sf::Texture("hill.png"); + textures[TextureType::Texture_Forest] = sf::Texture("forest.png"); + textures[TextureType::Texture_Stone] = sf::Texture("stone.png"); + textures[TextureType::Texture_Sand] = sf::Texture("sand.png"); + textures[TextureType::Texture_Snow] = sf::Texture("snow.png"); + textures[TextureType::Texture_Water] = sf::Texture("water.png"); + textures[TextureType::Texture_Hide] = sf::Texture("hide.png"); + textures[TextureType::Texture_Soup] = sf::Texture("soup.png"); + + + for (int x = 0; x < CELLSIZE_M; x++) { + for (int y = 0; y < CELLSIZE_N; y++) { + + // TODO функцию а не напрямую + if (cells[x][y].isHidden) + shapes[x][y].setTexture(&textures[TextureType::Texture_Hide]); + else + shapes[x][y].setTexture(&textures[cells[x][y].cellType]); + + shapes[x][y].setPosition( + sf::Vector2f(x * CELLSIZE_SCREEN, y * CELLSIZE_SCREEN)); + shapes[x][y].setSize({ CELLSIZE_SCREEN, CELLSIZE_SCREEN }); + } + } + + bool mousepressed = false; + while (window.isOpen()) { + + while (const std::optional event = window.pollEvent()) { + if (event->is()) + window.close(); + + if (const auto* keyPressed = event->getIf()) { + if (keyPressed->scancode == sf::Keyboard::Scancode::Escape) + window.close(); + } + + if (!sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + mousepressed = false; + } + + if (!mousepressed && sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { + mousepressed = true; + mouseCoord = sf::Mouse::getPosition(window); + + clickTile(energy, hp, mouseCoord, cells, shapes, textures); + energy--; + textEnergy.setString(std::to_wstring(energy)); + textHp.setString(L"\n" + std::to_wstring(hp)); + + if (isWinOfGame(cells)) + textCondition.setString("WINNER!!!"); + if (isLoseOfGame(energy, hp)) + textCondition.setString("LOSER!!!"); + } + } + + window.clear(); + for (int x = 0; x < CELLSIZE_M; x++) { + for (int y = 0; y < CELLSIZE_N; y++) { + window.draw(shapes[x][y]); + } + } + window.draw(textHp); + window.draw(textEnergy); + window.draw(textCondition); + window.display(); + } +} + + +// Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки" +// Отладка программы: F5 или меню "Отладка" > "Запустить отладку" + +// Советы по началу работы +// 1. В окне обозревателя решений можно добавлять файлы и управлять ими. +// 2. В окне Team Explorer можно подключиться к системе управления версиями. +// 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения. +// 4. В окне "Список ошибок" можно просматривать ошибки. +// 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода. +// 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл. From 2a6c52f8d1ef03e86924478cb6f435c83e408a57 Mon Sep 17 00:00:00 2001 From: Romanova Sofya Date: Tue, 20 May 2025 22:54:51 +0300 Subject: [PATCH 3/4] ..... --- Task2.cpp | 36 ------------------------------------ task2.cpp | 22 ---------------------- 2 files changed, 58 deletions(-) delete mode 100644 Task2.cpp delete mode 100644 task2.cpp diff --git a/Task2.cpp b/Task2.cpp deleted file mode 100644 index 755f86a9..00000000 --- a/Task2.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Task2.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы. -// -#include -using std::cin; -using std::cout; - -void TrapezoidArea() { - int base1 = 0; - int base2 = 0; - int height = 0; - cin >> base1; - cout << "Enter the length of the second base of the trapezoid"; - cin >> base2; - cout << "Enter the length of the trapezoid height"; - cin >> height; - cout << "Trapezoid area:"; - cout << (((base1 + base2)/2) * height); - return; - -} -int main() -{ - cout << "Enter the length of the first base of the trapezoid"; - TrapezoidArea(); -} - -// Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки" -// Отладка программы: F5 или меню "Отладка" > "Запустить отладку" - -// Советы по началу работы -// 1. В окне обозревателя решений можно добавлять файлы и управлять ими. -// 2. В окне Team Explorer можно подключиться к системе управления версиями. -// 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения. -// 4. В окне "Список ошибок" можно просматривать ошибки. -// 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода. -// 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл. diff --git a/task2.cpp b/task2.cpp deleted file mode 100644 index 398974e9..00000000 --- a/task2.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -void fun(int a) -{ - std::string num = ""; - - while (a > 0) - { - num = std::to_string(a % 8) + num; - a = a / 8; - } - - std::cout << num; -} - -int main() -{ - int a; - std::cin >> a; - fun(a); -} \ No newline at end of file From 65ceee4b56d6426ebf7009072eb68014896b3899 Mon Sep 17 00:00:00 2001 From: Romanova Sofya Date: Tue, 10 Jun 2025 21:03:09 +0300 Subject: [PATCH 4/4] miniHW_2 --- miniHW_2.cpp => sem2_RomanovaSofya/miniHW_2.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename miniHW_2.cpp => sem2_RomanovaSofya/miniHW_2.cpp (100%) diff --git a/miniHW_2.cpp b/sem2_RomanovaSofya/miniHW_2.cpp similarity index 100% rename from miniHW_2.cpp rename to sem2_RomanovaSofya/miniHW_2.cpp