#include <SFML/Graphics.hpp>
int main()
{
//Example for making a rectangle move around
sf::RenderWindow screen(sf::VideoMode(1024, 768) "Rectangle shape test"); //Create a window
screen.setFramerateLimit(60); //Limit the frame rate to 60
sf::RectangleShape rectangle; //Instantiate rectangle object
rectangle.setFillColor(sf::Color::Blue); //Color the rectangle with blue
rectangle.setPosition(100, 100); //Set the rectangle's position to 100, 100
while (screen.isOpen()) //loop to update the window
{
sf::Event event; //Create an event class
while (screen.pollEvent(event)) //Poll all possible events
{
if (event.type == sf::Event::Closed) //If the user hits the red X button
screen.close(); //If true, close the window
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) //If the user is holding down the key "W"
rectangle.move(0, 5); //move the rectangle 5 pixels on the y axis
}
screen.clear(); //Clear the screen of all elements
screen.draw(rectangle); //Draw the rectangle
screen.display(); //Display it
}
}
This should work, I haven't tested it so tell me if there's any errors. Probably careless ones on my part. Also, the only reason I wrote this code for you is to start off. Nobody in the community will write much code for you, so you'll have to learn the API. Start reading the documentation here:
http://www.sfml-dev.org/documentation/2.0/. There's tutorials here:
http://www.sfml-dev.org/tutorials/2.0/. Notice that I gave you documentation and tutorials for SFML 2.0, which is what everybody should be using. Make sure that you're using that version. Anyways, I hope that you stay around and eventually make some badass games