Hi, Im new here on sfml forums and right now im trying to make a simple pong game in sfml 1.6.
When I get to making the shape of the second paddle, when I compile, it doesn't show up right. Like I put the exact parameters but it shows up in a different place.
Here's the code I have so far:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow Window (sf::VideoMode(640, 480, 32), "Pong");
sf::Shape paddle1 = sf::Shape::Rectangle(0, 100, 10, 10, sf::Color(255, 0, 0));
sf::Shape paddle2 = sf::Shape::Rectangle(0, 0, 10, 10, sf::Color(255,0,0)); // I put the parameters 0, 0 in here but the rectangle shows up in a different spot on the screen
sf::Shape ball = sf::Shape::Circle(320, 240, 10, sf::Color(255,0,0));
while(Window.IsOpened())
{
sf::Event Event;
while(Window.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
Window.Close();
}
if(Window.GetInput().IsKeyDown(sf::Key::Down))
paddle1.Move(0.0, 2.0);
if(Window.GetInput().IsKeyDown(sf::Key::Up))
paddle1.Move(0.0, -2.0);
Window.Clear(sf::Color(255,255,255));
Window.Draw(paddle1);
Window.Draw(paddle2);
Window.Draw(ball);
Window.Display();
sf::Sleep(0.06);
}
}