diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_system.cpp | 5 | ||||
| -rw-r--r-- | src/message_system.cpp | 24 | ||||
| -rw-r--r-- | src/message_system.h | 10 | ||||
| -rw-r--r-- | src/renderer.cpp | 15 | ||||
| -rw-r--r-- | src/renderer.h | 1 |
5 files changed, 51 insertions, 4 deletions
| diff --git a/src/input_system.cpp b/src/input_system.cpp index e8b2bb9..b70b377 100644 --- a/src/input_system.cpp +++ b/src/input_system.cpp | |||
| @@ -32,8 +32,9 @@ void InputSystem::tick(double dt) { | |||
| 32 | } else { | 32 | } else { |
| 33 | game_.getSystem<MessageSystem>().displayCutsceneBars(); | 33 | game_.getSystem<MessageSystem>().displayCutsceneBars(); |
| 34 | }*/ | 34 | }*/ |
| 35 | //game_.getSystem<MessageSystem>().displayMessage("Some people always try to avoid fighting when there are enemies around. You know the type, right? They use the dash ability to zoom right by. I guess you could say they're followers of \"peace at any price\".", SpeakerType::Woman); | 35 | game_.getSystem<MessageSystem>().displayMessage("Some people always try to avoid fighting when there are enemies around. You know the type, right? They use the dash ability to zoom right by. I guess you could say they're followers of \"peace at any price\".", "Sparrow", SpeakerType::Woman); |
| 36 | game_.getSystem<MessageSystem>().displayMessage("Lucas. You're awful at hide-and-seek, you know that? Try harder.", "Kumatora", SpeakerType::Woman); | 36 | //game_.getSystem<MessageSystem>().displayMessage("Lucas. You're awful at hide-and-seek, you know that? Try harder.", "Kumatora", SpeakerType::Woman); |
| 37 | //game_.getSystem<MessageSystem>().displayMessage("Hi Tooth! I hope you're having a good day.", "Lucas", SpeakerType::Boy); | ||
| 37 | } else if (e.key.keysym.sym == SDLK_b) { | 38 | } else if (e.key.keysym.sym == SDLK_b) { |
| 38 | // TODO: Remove this, it's just for testing. | 39 | // TODO: Remove this, it's just for testing. |
| 39 | game_.getSystem<MessageSystem>().advanceText(); | 40 | game_.getSystem<MessageSystem>().advanceText(); |
| diff --git a/src/message_system.cpp b/src/message_system.cpp index 08ef799..0b0d53e 100644 --- a/src/message_system.cpp +++ b/src/message_system.cpp | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | #include "util.h" | 3 | #include "util.h" |
| 4 | 4 | ||
| 5 | const int CHARS_TO_REVEAL = 1; | 5 | const int CHARS_TO_REVEAL = 1; |
| 6 | const int CHARS_PER_BEEP = 10; | 6 | const int CHARS_PER_BEEP = 8; |
| 7 | 7 | ||
| 8 | void MessageSystem::tick(double dt) { | 8 | void MessageSystem::tick(double dt) { |
| 9 | if (barsState_ == BarsState::Opening || barsState_ == BarsState::Closing) { | 9 | if (barsState_ == BarsState::Opening || barsState_ == BarsState::Closing) { |
| @@ -59,6 +59,27 @@ void MessageSystem::tick(double dt) { | |||
| 59 | 59 | ||
| 60 | linesToShow_.push_back(MessageLine { .text = lines_.front() }); | 60 | linesToShow_.push_back(MessageLine { .text = lines_.front() }); |
| 61 | lines_.pop_front(); | 61 | lines_.pop_front(); |
| 62 | } else { | ||
| 63 | showNextArrow_ = true; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | if (showNextArrow_) { | ||
| 69 | nextArrowBobTimer_.accumulate(dt); | ||
| 70 | while (nextArrowBobTimer_.step()) { | ||
| 71 | if (nextArrowBobDown_) { | ||
| 72 | nextArrowBobPos_++; | ||
| 73 | |||
| 74 | if (nextArrowBobPos_ >= 4) { | ||
| 75 | nextArrowBobDown_ = false; | ||
| 76 | } | ||
| 77 | } else { | ||
| 78 | nextArrowBobPos_--; | ||
| 79 | |||
| 80 | if (nextArrowBobPos_ <= 0) { | ||
| 81 | nextArrowBobDown_ = true; | ||
| 82 | } | ||
| 62 | } | 83 | } |
| 63 | } | 84 | } |
| 64 | } | 85 | } |
| @@ -172,6 +193,7 @@ void MessageSystem::advanceText() { | |||
| 172 | } | 193 | } |
| 173 | 194 | ||
| 174 | lines_.pop_front(); | 195 | lines_.pop_front(); |
| 196 | showNextArrow_ = false; | ||
| 175 | 197 | ||
| 176 | if (lines_.empty()) { | 198 | if (lines_.empty()) { |
| 177 | linesToShow_.clear(); | 199 | linesToShow_.clear(); |
| diff --git a/src/message_system.h b/src/message_system.h index 18dd299..93ca087 100644 --- a/src/message_system.h +++ b/src/message_system.h | |||
| @@ -53,6 +53,10 @@ public: | |||
| 53 | 53 | ||
| 54 | const std::string& getSpeaker() const { return speakerName_; } | 54 | const std::string& getSpeaker() const { return speakerName_; } |
| 55 | 55 | ||
| 56 | bool isNextArrowShowing() const { return showNextArrow_; } | ||
| 57 | |||
| 58 | int getNextArrowBob() const { return nextArrowBobPos_; } | ||
| 59 | |||
| 56 | private: | 60 | private: |
| 57 | 61 | ||
| 58 | enum class BarsState { | 62 | enum class BarsState { |
| @@ -70,7 +74,11 @@ private: | |||
| 70 | std::string speakerName_; | 74 | std::string speakerName_; |
| 71 | std::list<std::string> lines_; | 75 | std::list<std::string> lines_; |
| 72 | std::list<MessageLine> linesToShow_; | 76 | std::list<MessageLine> linesToShow_; |
| 73 | Timer textAdvTimer_ { 10 }; | 77 | Timer textAdvTimer_ { 15 }; |
| 78 | bool showNextArrow_ = false; | ||
| 79 | int nextArrowBobPos_ = 0; | ||
| 80 | bool nextArrowBobDown_ = true; | ||
| 81 | Timer nextArrowBobTimer_ { 125 }; | ||
| 74 | }; | 82 | }; |
| 75 | 83 | ||
| 76 | #endif /* end of include guard: MESSAGE_SYSTEM_H_DE10D011 */ | 84 | #endif /* end of include guard: MESSAGE_SYSTEM_H_DE10D011 */ |
| diff --git a/src/renderer.cpp b/src/renderer.cpp index ae18851..4f5b4ff 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp | |||
| @@ -205,6 +205,21 @@ void Renderer::render(Game& game) { | |||
| 205 | 205 | ||
| 206 | lineIndex++; | 206 | lineIndex++; |
| 207 | } | 207 | } |
| 208 | |||
| 209 | // 216, 138, 142 | ||
| 210 | if (game.getSystem<MessageSystem>().isNextArrowShowing()) { | ||
| 211 | if (advMsgArrowTex_ == -1) { | ||
| 212 | advMsgArrowTex_ = loadImageFromFile("../res/advance_text_arrow.png"); | ||
| 213 | } | ||
| 214 | |||
| 215 | SDL_Rect destRect { | ||
| 216 | 216, | ||
| 217 | 138 + game.getSystem<MessageSystem>().getNextArrowBob(), | ||
| 218 | 16, | ||
| 219 | 16 }; | ||
| 220 | |||
| 221 | SDL_RenderCopy(ren_.get(), textures_.at(advMsgArrowTex_).get(), nullptr, &destRect); | ||
| 222 | } | ||
| 208 | } | 223 | } |
| 209 | } | 224 | } |
| 210 | 225 | ||
| diff --git a/src/renderer.h b/src/renderer.h index 4195d11..b812429 100644 --- a/src/renderer.h +++ b/src/renderer.h | |||
| @@ -150,6 +150,7 @@ private: | |||
| 150 | MessageCache messageLines_[2]; | 150 | MessageCache messageLines_[2]; |
| 151 | int speakerHeaderTex_ = -1; | 151 | int speakerHeaderTex_ = -1; |
| 152 | MessageCache speakerHeaderLine_; | 152 | MessageCache speakerHeaderLine_; |
| 153 | int advMsgArrowTex_ = -1; | ||
| 153 | }; | 154 | }; |
| 154 | 155 | ||
| 155 | #endif /* end of include guard: RENDERER_H_6A58EC30 */ | 156 | #endif /* end of include guard: RENDERER_H_6A58EC30 */ |
