summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp39
-rw-r--r--src/game.h10
-rw-r--r--src/renderer.cpp13
-rw-r--r--src/renderer.h1
4 files changed, 62 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index 39828f4..98745f4 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -18,6 +18,7 @@ Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) :
18{ 18{
19 losePopLampTimer.accumulate(losePopLampTimer.getDt()); 19 losePopLampTimer.accumulate(losePopLampTimer.getDt());
20 initialFade.start(1000); 20 initialFade.start(1000);
21 helpProgress.start(1500);
21 22
22 do { 23 do {
23 loadMap(); 24 loadMap();
@@ -954,6 +955,44 @@ void Game::updatePlaying(size_t frameTime) {
954 } 955 }
955 } 956 }
956 957
958 switch (helpState) {
959 case HelpState::PreWait: {
960 helpProgress.tick(frameTime);
961 if (helpProgress.isComplete()) {
962 helpState = HelpState::FadeIn;
963 helpProgress.start(1000);
964 }
965 break;
966 }
967 case HelpState::FadeIn: {
968 helpProgress.tick(frameTime);
969 if (helpProgress.isComplete()) {
970 helpState = HelpState::Hold;
971 helpProgress.start(3000);
972 }
973 break;
974 }
975 case HelpState::Hold: {
976 helpProgress.tick(frameTime);
977 if (helpProgress.isComplete()) {
978 helpState = HelpState::FadeOut;
979 helpProgress.start(1000);
980 }
981 break;
982 }
983 case HelpState::FadeOut: {
984 helpProgress.tick(frameTime);
985 if (helpProgress.isComplete()) {
986 helpState = HelpState::Done;
987 }
988 break;
989 }
990 case HelpState::Done: {
991 // Do nothing.
992 break;
993 }
994 }
995
957 switch (signInstructionState) { 996 switch (signInstructionState) {
958 case SignInstructionState::Hidden: { 997 case SignInstructionState::Hidden: {
959 auto [lookX, lookY] = coordInDirection(player_x, player_y, playerAnim.getDirection()); 998 auto [lookX, lookY] = coordInDirection(player_x, player_y, playerAnim.getDirection());
diff --git a/src/game.h b/src/game.h index 914df53..5bdc245 100644 --- a/src/game.h +++ b/src/game.h
@@ -30,6 +30,14 @@ enum class LoseState {
30 Done 30 Done
31}; 31};
32 32
33enum class HelpState {
34 PreWait,
35 FadeIn,
36 Hold,
37 FadeOut,
38 Done
39};
40
33struct Input { 41struct Input {
34 bool left = false; 42 bool left = false;
35 bool right = false; 43 bool right = false;
@@ -72,6 +80,8 @@ public:
72 80
73 Interpolation initialFade; 81 Interpolation initialFade;
74 bool startedMusic = false; 82 bool startedMusic = false;
83 HelpState helpState = HelpState::PreWait;
84 Interpolation helpProgress;
75 85
76 Map map; 86 Map map;
77 std::list<Kickup> kickups; 87 std::list<Kickup> kickups;
diff --git a/src/renderer.cpp b/src/renderer.cpp index 5d6ac08..2fc6023 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -120,6 +120,7 @@ void Renderer::loadAllTextures() {
120 loadTextureFromFile("lamp.png", lamp_); 120 loadTextureFromFile("lamp.png", lamp_);
121 loadTextureFromFile("read_instruction.png", readInstruction_); 121 loadTextureFromFile("read_instruction.png", readInstruction_);
122 loadTextureFromFile("menu.png", menuBg_); 122 loadTextureFromFile("menu.png", menuBg_);
123 loadTextureFromFile("help.png", help_);
123 124
124 loadTextureFromFile("title0.png", titles_[0]); 125 loadTextureFromFile("title0.png", titles_[0]);
125 SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]); 126 SDL_QueryTexture(titles_[0].get(), nullptr, nullptr, &titleWidths_[0], &titleHeights_[0]);
@@ -424,7 +425,17 @@ void Renderer::renderGame(
424 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, 0); 425 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, 0);
425 SDL_RenderClear(ren_.get()); 426 SDL_RenderClear(ren_.get());
426 427
427 if (game.signInstructionState != SignInstructionState::Hidden) { 428 if (game.helpState == HelpState::FadeIn || game.helpState == HelpState::Hold || game.helpState == HelpState::FadeOut) {
429 int instOpacity = 255;
430 if (game.helpState == HelpState::FadeIn) {
431 instOpacity = game.helpProgress.getProgress(0, 255);
432 } else if (game.helpState == HelpState::FadeOut) {
433 instOpacity = game.helpProgress.getProgress(255, 0);
434 }
435
436 SDL_SetTextureAlphaMod(help_.get(), instOpacity);
437 SDL_RenderCopy(ren_.get(), help_.get(), nullptr, nullptr);
438 } else if (game.signInstructionState != SignInstructionState::Hidden) {
428 int instOpacity = 255; 439 int instOpacity = 255;
429 if (game.signInstructionState == SignInstructionState::FadingIn) { 440 if (game.signInstructionState == SignInstructionState::FadingIn) {
430 instOpacity = game.signFade.getProgress(0, 255); 441 instOpacity = game.signFade.getProgress(0, 255);
diff --git a/src/renderer.h b/src/renderer.h index f650736..549f64a 100644 --- a/src/renderer.h +++ b/src/renderer.h
@@ -187,6 +187,7 @@ private:
187 texture_ptr lamp_; 187 texture_ptr lamp_;
188 texture_ptr readInstruction_; 188 texture_ptr readInstruction_;
189 texture_ptr menuBg_; 189 texture_ptr menuBg_;
190 texture_ptr help_;
190 191
191 std::array<texture_ptr, NUM_TITLES> titles_; 192 std::array<texture_ptr, NUM_TITLES> titles_;
192 std::array<int, NUM_TITLES> titleWidths_; 193 std::array<int, NUM_TITLES> titleWidths_;