Untitled
unknown
plain_text
a year ago
6.1 kB
5
Indexable
#include <SFML/Graphics.hpp> #include <stdlib.h> #include <iostream> #include <chrono> #include <string> int main() { setlocale(LC_ALL, "Russian"); int a; std::cout << "Выберите уровень сложности:"; std::cout << "1-легкий, 2-средний, 3-сложный"; std::cin >> a; sf::RenderWindow window(sf::VideoMode(1920, 1080, 60), "Heat the Angry Loki bobo"); sf::RectangleShape rectangle(sf::Vector2f(50.f, 50.f)); rectangle.setSize(sf::Vector2f(800.f, 500.f)); rectangle.setPosition(600.f, 250.f); rectangle.setFillColor(sf::Color(128, 128, 128)); srand(std::chrono::steady_clock::now().time_since_epoch().count()); int start = 600; int end = 1240; int start1 = 250; int end1 = 600; int x = rand() % (end - start + 1) + start; int y = rand() % (end1 - start1 + 1) + start1; sf::CircleShape shape(70.f); shape.setPosition((float)x, (float)y); sf::Texture sobaka; sobaka.loadFromFile("C:\\Users\\Ulyana\\Desktop\\images\\proekt.png"); sf::Sprite sobaka228; sobaka228.setTexture(sobaka); sobaka228.setScale(0.15, 0.15f); sobaka228.setPosition((float)x, (float)y); sf::Font font; font.loadFromFile("C:\\Users\\Ulyana\\Downloads\\Roboto\\Roboto-Black.ttf"); int Score = 0; sf::Text score; score.setString("Score: " + std::to_string(Score)); score.setCharacterSize(50); score.setFillColor(sf::Color::Red); score.setPosition(100, 100); score.setFont(font); switch (a) { case 1: { int t = 300; int a = 0; while (window.isOpen()) { window.clear(); window.draw(rectangle); score.setString("Score: " + std::to_string(Score)); window.draw(score); int e = sf::Mouse::getPosition().x; int b = sf::Mouse::getPosition().y; if (t > 0) { window.draw(sobaka228); t--; } else { a += 1; x = rand() % (end - start + 1) + start; y = rand() % (end1 - start1 + 1) + start1; t = 300; sobaka228.setPosition((float)x, (float)y); } sf::Event event; while (window.pollEvent(event)) { if (x <= e && e <= x + 800 * 0.15 && y <= b - 38 && b - 38 <= y + 733 * 0.15 && event.type == sf::Event::MouseButtonPressed) { Score++; a += 1; x = rand() % (end - start + 1) + start; y = rand() % (end1 - start1 + 1) + start1; t = 300; sobaka228.setPosition((float)x, (float)y); } if (event.type == sf::Event::Closed) { window.close(); } } window.display(); } return 0; } case 2: { int t = 120; int a = 0; while (window.isOpen()) { window.clear(); window.draw(rectangle); score.setString("Score: " + std::to_string(Score)); window.draw(score); int e = sf::Mouse::getPosition().x; int b = sf::Mouse::getPosition().y; if (t > 0) { window.draw(sobaka228); t--; } else { a += 1; x = rand() % (end - start + 1) + start; y = rand() % (end1 - start1 + 1) + start1; t = 120; sobaka228.setPosition((float)x, (float)y); } sf::Event event; while (window.pollEvent(event)) { if (x <= e && e <= x + 800 * 0.15 && y <= b - 38 && b - 38 <= y + 733 * 0.15 && event.type == sf::Event::MouseButtonPressed) { Score++; a += 1; x = rand() % (end - start + 1) + start; y = rand() % (end1 - start1 + 1) + start1; t = 120; sobaka228.setPosition((float)x, (float)y); } if (event.type == sf::Event::Closed) { window.close(); } } window.display(); } return 0; } case 3: { int t = 60; int a = 0; while (window.isOpen()) { window.clear(); window.draw(rectangle); score.setString("Score: " + std::to_string(Score)); window.draw(score); int e = sf::Mouse::getPosition().x; int b = sf::Mouse::getPosition().y; if (t > 0) { window.draw(sobaka228); t--; } else { a += 1; x = rand() % (end - start + 1) + start; y = rand() % (end1 - start1 + 1) + start1; t = 60; sobaka228.setPosition((float)x, (float)y); } sf::Event event; while (window.pollEvent(event)) { if (x <= e && e <= x + 800 * 0.15 && y <= b - 38 && b - 38 <= y + 733 * 0.15 && event.type == sf::Event::MouseButtonPressed) { Score++; a += 1; x = rand() % (end - start + 1) + start; y = rand() % (end1 - start1 + 1) + start1; t = 60; sobaka228.setPosition((float)x, (float)y); } if (event.type == sf::Event::Closed) { window.close(); } } window.display(); } return 0; } default: std::cout << "Выберите из предложенных"; } }
Editor is loading...
Leave a Comment