Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int width = 800;
- int height = 600;
- int x = width/2;
- int y = height/2;
- int main()
- {
- sf::RenderWindow window(sf::VideoMode(width, height), "Generic name for a window");
- window.setFramerateLimit(60);
- sf::CircleShape circle(70.f);
- circle.setFillColor(sf::Color::Black);
- circle.setOutlineThickness(15.f);
- circle.setOutlineColor(sf::Color::Green);
- sf::Event event;
- while (window.isOpen())
- {
- window.clear(sf::Color::White);
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- window.close();
- if (event.type == sf::Event::KeyPressed)
- {
- if (event.key.code == sf::Keyboard::Up)
- {
- if (y - 10 < 0)
- ;
- else
- y -= 10;
- }
- else if (event.key.code == sf::Keyboard::Down)
- {
- if (y + 10 > height)
- ;
- else
- y += 10;
- }
- else if (event.key.code == sf::Keyboard::Left)
- {
- if (x - 10 < 0)
- ;
- else
- x -= 10;
- }
- else if (event.key.code == sf::Keyboard::Right)
- {
- if (x + 10 > width)
- ;
- else
- x += 10;
- }
- }
- }
- circle.setPosition(x, y);
- window.draw(circle);
- window.display();
- }
- int pause; cin >> pause; //Pause the program
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement