summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp14
-rw-r--r--src/game.h6
-rw-r--r--src/muxer.cpp14
-rw-r--r--src/muxer.h2
-rw-r--r--src/renderer.cpp6
5 files changed, 36 insertions, 6 deletions
diff --git a/src/game.cpp b/src/game.cpp index 72bcbfa..caa465c 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -16,6 +16,7 @@ Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) :
16 sign(renderer.getFont()) 16 sign(renderer.getFont())
17{ 17{
18 losePopLampTimer.accumulate(losePopLampTimer.getDt()); 18 losePopLampTimer.accumulate(losePopLampTimer.getDt());
19 initialFade.start(1000);
19 20
20 do { 21 do {
21 loadMap(); 22 loadMap();
@@ -846,6 +847,19 @@ void Game::updatePlaying(size_t frameTime) {
846 847
847 switch (losing) 848 switch (losing)
848 { 849 {
850 case LoseState::NewGame:
851 {
852 if (!startedMusic) {
853 startedMusic = true;
854 muxer.startMusic();
855 }
856 initialFade.tick(frameTime);
857 if (initialFade.isComplete()) {
858 losing = LoseState::None;
859 }
860 break;
861 }
862
849 case LoseState::None: 863 case LoseState::None:
850 { 864 {
851 if (moving) { 865 if (moving) {
diff --git a/src/game.h b/src/game.h index 839be67..3b092dd 100644 --- a/src/game.h +++ b/src/game.h
@@ -21,6 +21,7 @@ constexpr int TilesetIndex(int x, int y) {
21} 21}
22 22
23enum class LoseState { 23enum class LoseState {
24 NewGame,
24 None, 25 None,
25 PoppingLamps, 26 PoppingLamps,
26 PoppingPlayer, 27 PoppingPlayer,
@@ -66,7 +67,10 @@ public:
66 67
67 bool quit = false; 68 bool quit = false;
68 bool quitting = false; // <- whether we will quit after losing, vs starting a new game 69 bool quitting = false; // <- whether we will quit after losing, vs starting a new game
69 LoseState losing = LoseState::None; 70 LoseState losing = LoseState::NewGame;
71
72 Interpolation initialFade;
73 bool startedMusic = false;
70 74
71 Map map; 75 Map map;
72 std::list<Kickup> kickups; 76 std::list<Kickup> kickups;
diff --git a/src/muxer.cpp b/src/muxer.cpp index c93c45a..6ae6936 100644 --- a/src/muxer.cpp +++ b/src/muxer.cpp
@@ -26,11 +26,6 @@ Muxer::Muxer() {
26 26
27 FMOD::Studio::Bank* stringsBank = nullptr; 27 FMOD::Studio::Bank* stringsBank = nullptr;
28 ERRCHECK(system_->loadBankFile("../res/fmod/Build/Desktop/Master Bank.strings.bank", FMOD_STUDIO_LOAD_BANK_NORMAL, &stringsBank)); 28 ERRCHECK(system_->loadBankFile("../res/fmod/Build/Desktop/Master Bank.strings.bank", FMOD_STUDIO_LOAD_BANK_NORMAL, &stringsBank));
29
30 FMOD::Studio::EventDescription* exploration_desc = nullptr;
31 ERRCHECK(system_->getEvent("event:/exploration", &exploration_desc));
32 ERRCHECK(exploration_desc->createInstance(&exploration_event_));
33 ERRCHECK(exploration_event_->start());
34} 29}
35 30
36void Muxer::setPlayerLoc(int x, int y) { 31void Muxer::setPlayerLoc(int x, int y) {
@@ -96,6 +91,15 @@ void Muxer::setMusicLevel(int level) {
96 } 91 }
97} 92}
98 93
94void Muxer::startMusic() {
95 FMOD::Studio::EventDescription* exploration_desc = nullptr;
96 ERRCHECK(system_->getEvent("event:/exploration", &exploration_desc));
97 ERRCHECK(exploration_desc->createInstance(&exploration_event_));
98 ERRCHECK(exploration_event_->start());
99
100 transition_state_ = TransitionState::Pre;
101}
102
99void Muxer::stopMusic() { 103void Muxer::stopMusic() {
100 switch (transition_state_) { 104 switch (transition_state_) {
101 case TransitionState::Pre: { 105 case TransitionState::Pre: {
diff --git a/src/muxer.h b/src/muxer.h index 9750808..acceca8 100644 --- a/src/muxer.h +++ b/src/muxer.h
@@ -34,6 +34,8 @@ public:
34 34
35 void setMusicLevel(int level); 35 void setMusicLevel(int level);
36 36
37 void startMusic();
38
37 void stopMusic(); 39 void stopMusic();
38 40
39 void update(); 41 void update();
diff --git a/src/renderer.cpp b/src/renderer.cpp index b24ddbf..b6a9b4a 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -396,6 +396,12 @@ void Renderer::renderGame(
396 396
397 SDL_RenderCopy(ren_.get(), canvas.get(), &zoomRect, nullptr); 397 SDL_RenderCopy(ren_.get(), canvas.get(), &zoomRect, nullptr);
398 398
399 if (game.losing == LoseState::NewGame) {
400 SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_BLEND);
401 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, game.initialFade.getProgress(255, 0));
402 SDL_RenderFillRect(ren_.get(), nullptr);
403 }
404
399 texture_ptr overlays( 405 texture_ptr overlays(
400 SDL_CreateTexture( 406 SDL_CreateTexture(
401 ren_.get(), 407 ren_.get(),