Compile & Play!
Pong in C++
Your first C++ game with the SFML library: two paddles, a bouncing ball, scores and an AI. C++ powers Unreal, most AAA studios and every console, and it starts right here with Pong.
Your first C++ game with the SFML library: two paddles, a bouncing ball, scores and an AI. C++ powers Unreal, most AAA studios and every console, and it starts right here with Pong.
main.cpp plus a build file, right in the browser with no install. Open the C++ Mod Studio →-lsfml-graphics -lsfml-window -lsfml-systemsf::VideoMode({800, 500})sf::VideoMode({800, 500}) (curly braces), the new event loop while (const std::optional e = window.pollEvent())while (const std::optional e = window.pollEvent()) with e->is<sf::Event::Closed>()e->is<sf::Event::Closed>(), sf::Keyboard::Key::Leftsf::Keyboard::Key::Left (add ::Key::Key), and setPosition({x, y})setPosition({x, y}) / move({dx, dy})move({dx, dy}) (curly braces). The ? complete finished code at the bottom of this page is full SFML 3 and compiles on a fresh install, use it as your reference.Each step adds one feature. Write the code, watch it come alive in the canvas, then make it your own.
Keep the SFML cheatsheet handy
Window, sprites and input in one place - use it beside this workshop.
Give your C++ Pong a look!
Use Pixel Studio to design a unique paddle and ball - make your Pong game stand out.
Build it in the browser first
Try this project step by step right here: write the code, watch it run, then download it and keep building in your engine.