Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <SFML/Graphics.hpp>
- #include <SFML/Window.hpp>
- using namespace std;
- int main()
- {
- sf::RenderWindow window(sf::VideoMode(800, 600), "Project");
- window.setFramerateLimit(70);
- window.setVerticalSyncEnabled(true);
- sf::RectangleShape square[14];
- for (int x = 0; x < 10; x++)
- {
- square[x].setSize(sf::Vector2f(50, 50));
- square[x].setFillColor(sf::Color::Blue);
- square[x].setPosition(x * 50, 0);
- }
- sf::Event event;
- while (window.isOpen())
- {
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- window.close();
- else if (event.type == sf::Event::KeyPressed)
- {
- for (int x = 0; x < 10; x++)
- {
- square[x].setPosition(square[x].getPosition().x + 3, square[x].getPosition().y);
- }
- }
- }
- for (int x = 0; x < 10; x++)
- {
- if (square[x].getPosition().y + 50 < 600)
- square[x].setPosition(square[x].getPosition().x, square[x].getPosition().y + 3);
- }
- window.clear(sf::Color::White); //Clear
- for (int x = 0; x < 10; x++)
- window.draw(square[x]);
- window.display(); //Display
- }
- int pause; cin >> pause; //Pause the program
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement