Can someone simpilfy this
My friend and I are learning c++ and SFML together to create a game.
We created something interesting and are wondering if there is a way to simplify what we have created.
Is there any way to make this entire thing shorter, or easier on the eyes? Please and thank you in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "Our Program");
while (window.isOpen())
{
window.clear(sf::Color::Black);
sf::VertexArray triangle(sf::Triangles, 3);
triangle[0].position = sf::Vector2f(10, 10);
triangle[1].position = sf::Vector2f(100, 10);
triangle[2].position = sf::Vector2f(100, 100);
triangle[0].color = sf::Color::Red;
triangle[1].color = sf::Color::Blue;
triangle[2].color = sf::Color::Green;
sf::Transform transform;
window.draw(triangle, transform);
Sleep(2000);
window.display();
for (int i = 1; i < 1000; i++)
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
return 0;
}
}
transform.translate(150, 150);
window.draw(triangle, transform);
Sleep(500);
window.display();
}
}
}
|
It's not really complex enough to start worrying about cleaning up the code.
Topic archived. No new replies allowed.