Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
3
Indexable
#include <SFML/Graphics.hpp>
#include <stdlib.h>
#include <iostream>
#include <chrono>

int main()
{
    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 = 1260;
    int start1 = 250;
    int end1 = 610;
    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);
   
    int t = 180;
    int a = 0;
    while (window.isOpen())
    {
        window.clear();
        window.draw(rectangle);
        
        if (t > 0) {
           window.draw(shape);
           t--;
        }
        else {
            a += 1; 
            x = rand() % (end - start + 1) + start; 
            y = rand() % (end1 - start1 + 1) + start1; 
            t = 180;
            shape.setPosition((float)x, (float)y);
        }
        
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.display();
    }
    return 0;
}
Leave a Comment