Leveling up
The next code we will add enables the player to level-up between waves. Because of the work we have already done that makes, this is straightforward to achieve.
Add the highlighted code in the LEVELING_UP
state where we handle player input:
// Handle the LEVELING up state if (state == State::LEVELING_UP) { // Handle the player LEVELING up if (event.key.code == Keyboard::Num1) { // Increase fire rate fireRate++; state = State::PLAYING; } if (event.key.code == Keyboard::Num2) { // Increase clip size clipSize += clipSize; state = State::PLAYING; } if (event.key.code == Keyboard::Num3) { // Increase health player.upgradeHealth(); state = State::PLAYING; } if (event.key.code == Keyboard::Num4) { // Increase speed player.upgradeSpeed(); ...
Get Beginning C++ Game Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.