const int WIDTH = 800;
const int HEIGHT = 600;
struct Ball
{
sf::CircleShape circle;
Ball(int width, int height)
{
float x = width / 2.f;
float y = height / 2.f;
float radius = 50.f;
circle.setRadius(radius);
sf::Color color = sf::Color::White;
circle.setFillColor(color);
circle.setPosition(sf::Vector2f(x, y));
};
};
int main()
{
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "Pong");
Ball pingPong = Ball(WIDTH, WIDTH);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Black);
window.draw(pingPong.circle);
window.display();
}
return 0;
}
clang++ Pong.cpp -std=c++11 -o PongExecutable -I/opt/homebrew/Cellar/sfml/2.6.1/include -L/opt/homebrew/Cellar/sfml/2.6.1/lib -lsfml-graphics -lsfml-window -lsfml-system