summary refs log tree commit diff stats
path: root/src/game.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-16 15:30:37 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-16 15:30:37 -0400
commit2c75d95ddf849996bfc18267a9eecb4d0f4e1916 (patch)
tree285315deeaf4b5153b5f92f0c8a23af557626204 /src/game.cpp
parent8713d03831226dcd559c6a1e2b1c7b0d7c660bac (diff)
downloadether-2c75d95ddf849996bfc18267a9eecb4d0f4e1916.tar.gz
ether-2c75d95ddf849996bfc18267a9eecb4d0f4e1916.tar.bz2
ether-2c75d95ddf849996bfc18267a9eecb4d0f4e1916.zip
signs can be read now!
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/game.cpp b/src/game.cpp index 301447f..5838528 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -7,9 +7,10 @@
7#include "renderer.h" 7#include "renderer.h"
8#include "consts.h" 8#include "consts.h"
9 9
10Game::Game(std::mt19937& rng, Muxer& muxer) : 10Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) :
11 rng(rng), 11 rng(rng),
12 muxer(muxer) 12 muxer(muxer),
13 sign(renderer.getFont())
13{ 14{
14 losePopLampTimer.accumulate(losePopLampTimer.getDt()); 15 losePopLampTimer.accumulate(losePopLampTimer.getDt());
15 16
@@ -631,7 +632,7 @@ void Game::performDash() {
631 } 632 }
632} 633}
633 634
634void Game::update(size_t frameTime) { 635void Game::updatePlaying(size_t frameTime) {
635 SDL_Event e; 636 SDL_Event e;
636 637
637 while (SDL_PollEvent(&e)) 638 while (SDL_PollEvent(&e))
@@ -666,8 +667,22 @@ void Game::update(size_t frameTime) {
666 { 667 {
667 if (losing == LoseState::None) 668 if (losing == LoseState::None)
668 { 669 {
670 auto [lookX, lookY] = coordInDirection(player_x, player_y, playerAnim.getDirection());
671 MapData& lookTile = map.at(lookX, lookY);
669 if (moving) { 672 if (moving) {
670 queueDash = true; 673 if (!lookTile.sign) {
674 queueDash = true;
675 }
676 } else if (lookTile.sign) {
677 if (lookTile.text.empty()) {
678 int lineToRead = nextSignIndex++;
679 if (nextSignIndex >= signTexts.size()) {
680 nextSignIndex = 0;
681 }
682 lookTile.text = signTexts[lineToRead];
683 }
684
685 sign.displayMessage(lookTile.text);
671 } else { 686 } else {
672 performDash(); 687 performDash();
673 } 688 }
@@ -815,7 +830,7 @@ void Game::update(size_t frameTime) {
815 switch (signInstructionState) { 830 switch (signInstructionState) {
816 case SignInstructionState::Hidden: { 831 case SignInstructionState::Hidden: {
817 auto [lookX, lookY] = coordInDirection(player_x, player_y, playerAnim.getDirection()); 832 auto [lookX, lookY] = coordInDirection(player_x, player_y, playerAnim.getDirection());
818 if (map.at(lookX, lookY).sign) { 833 if (losing == LoseState::None && map.at(lookX, lookY).sign) {
819 signInstructionState = SignInstructionState::FadingIn; 834 signInstructionState = SignInstructionState::FadingIn;
820 signFade.start(1000); 835 signFade.start(1000);
821 } 836 }
@@ -913,3 +928,11 @@ void Game::update(size_t frameTime) {
913 928
914 playerAnim.update(frameTime); 929 playerAnim.update(frameTime);
915} 930}
931
932void Game::update(size_t frameTime) {
933 if (sign.signDisplayState != SignInstructionState::Hidden) {
934 sign.update(frameTime, *this);
935 } else {
936 updatePlaying(frameTime);
937 }
938}