From 7b0ac7fc096b2dadb47780e9afd141395b6a111b Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 13 Mar 2021 09:41:52 -0500 Subject: Added cursor wrapping to pause menu #7 --- src/menu_system.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/menu_system.cpp b/src/menu_system.cpp index aaaa0e1..a6fd566 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp @@ -53,21 +53,27 @@ void MenuSystem::closePauseMenu() { } void MenuSystem::pressedUp() { - if (cursor_ > 0) { - cursor_--; - cursorBob_ = 0; - cursorBobDown_ = true; + cursor_--; - game_.getMixer().playSound("../res/sfx/vertical_menu.wav"); + if (cursor_ < 0) { + cursor_ = menu_.size() - 1; } + + cursorBob_ = 0; + cursorBobDown_ = true; + + game_.getMixer().playSound("../res/sfx/vertical_menu.wav"); } void MenuSystem::pressedDown() { - if (cursor_ < menu_.size() - 1) { - cursor_++; - cursorBob_ = 0; - cursorBobDown_ = true; + cursor_++; - game_.getMixer().playSound("../res/sfx/vertical_menu.wav"); + if (cursor_ >= menu_.size()) { + cursor_ = 0; } + + cursorBob_ = 0; + cursorBobDown_ = true; + + game_.getMixer().playSound("../res/sfx/vertical_menu.wav"); } -- cgit 1.4.1