summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-05 17:38:30 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-05 17:38:30 -0500
commitea78916cc43fe67690f2f92d88ac4a8b0e9857d8 (patch)
tree25054fa080f8a7d452b588d8031b254ee6ce998c /src
parentf7875a6d2f129af47a203a5a31c2785b6e2fcf58 (diff)
downloadtanetane-ea78916cc43fe67690f2f92d88ac4a8b0e9857d8.tar.gz
tanetane-ea78916cc43fe67690f2f92d88ac4a8b0e9857d8.tar.bz2
tanetane-ea78916cc43fe67690f2f92d88ac4a8b0e9857d8.zip
Added little bobbing "next message" arrow
Diffstat (limited to 'src')
-rw-r--r--src/input_system.cpp5
-rw-r--r--src/message_system.cpp24
-rw-r--r--src/message_system.h10
-rw-r--r--src/renderer.cpp15
-rw-r--r--src/renderer.h1
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
5const int CHARS_TO_REVEAL = 1; 5const int CHARS_TO_REVEAL = 1;
6const int CHARS_PER_BEEP = 10; 6const int CHARS_PER_BEEP = 8;
7 7
8void MessageSystem::tick(double dt) { 8void 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
56private: 60private:
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 */