summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 09:38:05 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2021-03-13 15:34:50 -0500
commit2581f03c00f5a14f49081d82eb8e1a31c31aae88 (patch)
treeaa7fd5864204408ff3c189b7b2351b6619d6f0cb
parentf839e07d4d2e94070129129c669072145235cf4f (diff)
downloadtanetane-2581f03c00f5a14f49081d82eb8e1a31c31aae88.tar.gz
tanetane-2581f03c00f5a14f49081d82eb8e1a31c31aae88.tar.bz2
tanetane-2581f03c00f5a14f49081d82eb8e1a31c31aae88.zip
Player can move cursor on pause menu
#7
-rw-r--r--res/sfx/vertical_menu.wavbin0 -> 31152 bytes
-rw-r--r--src/input_system.cpp8
-rw-r--r--src/menu_system.cpp20
-rw-r--r--src/menu_system.h4
4 files changed, 32 insertions, 0 deletions
diff --git a/res/sfx/vertical_menu.wav b/res/sfx/vertical_menu.wav new file mode 100644 index 0000000..9890c15 --- /dev/null +++ b/res/sfx/vertical_menu.wav
Binary files differ
diff --git a/src/input_system.cpp b/src/input_system.cpp index fd7889d..0c68c49 100644 --- a/src/input_system.cpp +++ b/src/input_system.cpp
@@ -126,6 +126,14 @@ void InputSystem::tick(double dt) {
126 if (game_.getSystem<MessageSystem>().isChoiceActive()) { 126 if (game_.getSystem<MessageSystem>().isChoiceActive()) {
127 game_.getSystem<MessageSystem>().selectSecondChoice(); 127 game_.getSystem<MessageSystem>().selectSecondChoice();
128 } 128 }
129 } else if (e.key.keysym.sym == SDLK_UP) {
130 if (game_.getSystem<MenuSystem>().isMenuOpen()) {
131 game_.getSystem<MenuSystem>().pressedUp();
132 }
133 } else if (e.key.keysym.sym == SDLK_DOWN) {
134 if (game_.getSystem<MenuSystem>().isMenuOpen()) {
135 game_.getSystem<MenuSystem>().pressedDown();
136 }
129 } 137 }
130 } else if (e.type == SDL_KEYUP && (e.key.keysym.sym == SDLK_LSHIFT || e.key.keysym.sym == SDLK_RSHIFT)) { 138 } else if (e.type == SDL_KEYUP && (e.key.keysym.sym == SDLK_LSHIFT || e.key.keysym.sym == SDLK_RSHIFT)) {
131 if (game_.isGameplayPaused()) continue; 139 if (game_.isGameplayPaused()) continue;
diff --git a/src/menu_system.cpp b/src/menu_system.cpp index acbfd76..d3a310e 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp
@@ -49,3 +49,23 @@ void MenuSystem::closePauseMenu() {
49 pauseAnimation_.start(125, 0.0); 49 pauseAnimation_.start(125, 0.0);
50 openState_ = OpenState::Animating; 50 openState_ = OpenState::Animating;
51} 51}
52
53void MenuSystem::pressedUp() {
54 if (cursor_ > 0) {
55 cursor_--;
56 cursorBob_ = 0;
57 cursorBobDown_ = true;
58
59 game_.getMixer().playSound("../res/sfx/vertical_menu.wav");
60 }
61}
62
63void MenuSystem::pressedDown() {
64 if (cursor_ < menu_.size() - 1) {
65 cursor_++;
66 cursorBob_ = 0;
67 cursorBobDown_ = true;
68
69 game_.getMixer().playSound("../res/sfx/vertical_menu.wav");
70 }
71}
diff --git a/src/menu_system.h b/src/menu_system.h index 9cbd1f0..fa373cb 100644 --- a/src/menu_system.h +++ b/src/menu_system.h
@@ -24,6 +24,10 @@ public:
24 24
25 void closePauseMenu(); 25 void closePauseMenu();
26 26
27 void pressedUp();
28
29 void pressedDown();
30
27 // Info 31 // Info
28 32
29 double getPauseAnimationProgress() const { return pauseAnimation_.getProgress(); } 33 double getPauseAnimationProgress() const { return pauseAnimation_.getProgress(); }