Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <SFML/Window.hpp>
- #include <windows.h>
- using namespace std;
- int main()
- {
- sf::Window window(sf::VideoMode(800, 600), "Generic name for a window");
- //First argument video mode determines the size of the window. In this case 800 pixels wide and 600 pixels long.
- //Second argument determines the name for the window.
- //sf in this case is just a namespace like std and can be erased from having to type out
- //by writing in in the beginning of the code "using namespace sf".
- /* Alternative way to creating a window
- sf::Window second_window;
- second_window.create(sf::VideoMode(400, 100), "The second window");
- */
- int x = 0;
- int y;
- window.setVerticalSyncEnabled(true); //Synchronize the refresh rate with the vertical frequency of the monitor.
- for (y = 0; y < 4; y++, x += 100)
- {
- window.setPosition(sf::Vector2i(x, 40));
- Sleep(1000);
- }
- Sleep(1000);
- window.setSize(sf::Vector2u(400, 400));
- Sleep(1000);
- window.setTitle("The name of the window just changed");
- // run the program as long as the window is open
- while (window.isOpen())
- {
- // check all the window's events that were triggered since the last iteration of the loop
- sf::Event event;
- while (window.pollEvent(event))
- {
- // "close requested" event: we close the window
- if (event.type == sf::Event::Closed)
- window.close();
- }
- }
- //The above code will open a window, and terminate when the user closes it.
- int pause;
- cin >> pause; //Pause the program
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement