Skip to content

Instantly share code, notes, and snippets.

@Mischa-Alff
Created October 11, 2014 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mischa-Alff/f9798fa0f816664e7b47 to your computer and use it in GitHub Desktop.
Save Mischa-Alff/f9798fa0f816664e7b47 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <SFML/Window.hpp>
int main()
{
sf::Window window(sf::VideoMode(800, 600), "test");
const sf::Vector2i desired_position(200, 200);
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
if(event.type == sf::Event::KeyPressed)
{
switch(event.key.code)
{
case sf::Keyboard::T:
window.setPosition(desired_position);
std::cout<<"Setting window position to: "<<desired_position.x<<", "<<desired_position.y<<std::endl;
break;
default:
break;
}
}
}
sf::Vector2i current_position = window.getPosition();
std::cout<<"Current window position: "<<current_position.x<<", "<<current_position.y<<std::endl;
window.display();
sf::sleep(sf::milliseconds(200));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment