đŽ Episode 7 âĸ Series Finale âĸ Tower Defence Part 2 of 2
Wave After Wave! Tower Defence Part 2
The grand finale: towers open fire with homing bullets, enemies arrive in escalating waves, kills pay bounties, towers upgrade, and a boss leads the final assault. Ship your biggest C++ project.
Build it in our C++ Studio too: lay out a level on a grid, tick the SFML features and download a real main.cpp plus a build file, right in the browser with no install. Open the C++ Mod Studio →
How to run: Save, compile and run: g++ game.cpp -o game -lsfml-graphics -lsfml-window -lsfml-system && ./game
đŽ
Heads up: SFML 3 renamed a few things. The install step gives you SFML 3 today, but the short snippets in the steps below are written in the classic SFML 2 style. The differences are small and mechanical: sf::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.
đŽ
Need the game so far? This episode continues Tower Defence Part 1, so it assumes you already have that project. Open your Part 1 file to keep building, or revisit it here: Tower Defence Part 1 ? âĸ C++ Cheatsheet ?
đ
How it works: write the code in each step, and the canvas on the right shows what your code does. It is a live preview that builds the game as you go. Type to see it update, or press Apply to Canvas to test it straight away.
đĻ
Lumo says: every step adds one feature to the same game. Type a little, click Apply to Canvas, and test it straight away. There is no wrong answer you can't undo.
Build Tower Defence Part 2 Step by Step
Each step adds one feature. Write the code, watch it come alive in the canvas, then make it your own.
Step 1 / 6
Upgraded towers and tougher waves
đŽđŽđŽđŽ?
Workshop Complete!
Seven episodes of C++: Pong to a full tower defence with waves, upgrades and a boss. You are a C++ game programmer now. Go build YOUR game. đŽđŽ