From f53ed222d3c0f570e422137ff238c6b285b6f2bd Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 28 Apr 2020 21:58:19 -0700 Subject: [PATCH] Interpolate activity zone prompt fading in and out To make it real smooth, just in case it was noticeable that it only updated at 1000/34 FPS before (well, except in slowmode, it's really noticeable THERE). Also this removes the re-typing out of (game.act_fade/10.0f) for every single R, G, and B in gamerender(). --- desktop_version/src/Game.cpp | 1 + desktop_version/src/Game.h | 1 + desktop_version/src/Logic.cpp | 1 + desktop_version/src/Render.cpp | 9 +++++---- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 14b44ec6..e4d3462f 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -150,6 +150,7 @@ void Game::init(void) completestop = false; activeactivity = -1; act_fade = 0; + prev_act_fade = 0; backgroundtext = false; startscript = false; newscript = ""; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index d9a647b8..48a669f1 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -327,6 +327,7 @@ public: bool backgroundtext; int activeactivity, act_fade; + int prev_act_fade; bool press_left, press_right, press_action, press_map; diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 7a6a4340..f9086f6c 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1516,6 +1516,7 @@ void gamelogic() } #endif + game.prev_act_fade = game.act_fade; if (game.activeactivity > -1) { if (game.act_fade < 5) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 66bf397e..055901d7 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1629,21 +1629,22 @@ void gamerender() } } + float act_alpha = graphics.lerp(game.prev_act_fade, game.act_fade) / 10.0f; if (game.activeactivity > -1) { game.activity_lastprompt = obj.blocks[game.activeactivity].prompt; game.activity_r = obj.blocks[game.activeactivity].r; game.activity_g = obj.blocks[game.activeactivity].g; game.activity_b = obj.blocks[game.activeactivity].b; - graphics.drawtextbox(16, 4, 36, 3, game.activity_r*(game.act_fade/10.0f), game.activity_g*(game.act_fade/10.0f), game.activity_b*(game.act_fade/10.0f)); - graphics.Print(5, 12, game.activity_lastprompt, game.activity_r*(game.act_fade/10.0f), game.activity_g*(game.act_fade/10.0f), game.activity_b*(game.act_fade/10.0f), true); + graphics.drawtextbox(16, 4, 36, 3, game.activity_r*act_alpha, game.activity_g*act_alpha, game.activity_b*act_alpha); + graphics.Print(5, 12, game.activity_lastprompt, game.activity_r*act_alpha, game.activity_g*act_alpha, game.activity_b*act_alpha, true); } else { if(game.act_fade>5) { - graphics.drawtextbox(16, 4, 36, 3, game.activity_r*(game.act_fade/10.0f), game.activity_g*(game.act_fade/10.0f), game.activity_b*(game.act_fade/10.0f)); - graphics.Print(5, 12, game.activity_lastprompt, game.activity_r*(game.act_fade/10.0f), game.activity_g*(game.act_fade/10.0f), game.activity_b*(game.act_fade/10.0f), true); + graphics.drawtextbox(16, 4, 36, 3, game.activity_r*act_alpha, game.activity_g*act_alpha, game.activity_b*act_alpha); + graphics.Print(5, 12, game.activity_lastprompt, game.activity_r*act_alpha, game.activity_g*act_alpha, game.activity_b*act_alpha, true); } }