Background fading transition added.

pull/28/head
sigonasr2 1 year ago
parent 88bafaec3f
commit b437202e13
  1. 2
      Crawler/Version.h
  2. 18
      Crawler/VisualNovel.cpp
  3. 1
      Crawler/VisualNovel.h
  4. 4
      Crawler/assets/config/story/Chapter 1.txt

@ -35,7 +35,7 @@ SUCH DAMAGE.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 3225
#define VERSION_BUILD 3226
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -177,11 +177,12 @@ void VisualNovel::LoadVisualNovel(std::string storyLevelName){
Menu::themeSelection="Purple";
}
void VisualNovel::Update(){
if(game->KEY_CONFIRM.Pressed()){
if(transitionTime==0&&game->KEY_CONFIRM.Pressed()){
activeText="";
novel.ExecuteNextCommand();
}
locationDisplayTime=std::max(0.f,locationDisplayTime-game->GetElapsedTime());
transitionTime=std::max(0.f,transitionTime-game->GetElapsedTime());
}
void VisualNovel::ExecuteNextCommand(){
if(commandIndex<commands.size()){
@ -195,7 +196,14 @@ void VisualNovel::ExecuteNextCommand(){
}
void VisualNovel::Draw(){
if(backgroundFilename!=""){
game->DrawDecal({0,0},GFX["backgrounds/"+backgroundFilename].Decal());
float alpha=1;
if(transitionTime>0){
alpha=util::lerp(0,1,1-(transitionTime/maxTransitionTime));
}
if(prevBackgroundFilename!=""){
game->DrawDecal({0,0},GFX["backgrounds/"+prevBackgroundFilename].Decal());
}
game->DrawDecal({0,0},GFX["backgrounds/"+backgroundFilename].Decal(),{1,1},{255,255,255,uint8_t(255*alpha)});
}else{
game->FillRectDecal({0,0},game->GetScreenSize());
}
@ -208,7 +216,9 @@ void VisualNovel::Draw(){
if(activeText.length()>0){
vf2d nameDisplayPos={24.f,game->GetScreenSize().y-60.f};
vf2d nameDisplayWindowSize={48.f,-12.f};
Menu::DrawThemedWindow(nameDisplayPos,nameDisplayWindowSize);
if(speakerDisplayName.length()>0){
Menu::DrawThemedWindow(nameDisplayPos,nameDisplayWindowSize);
}
vf2d dialogDisplayPos={24.f,game->GetScreenSize().y-48.f};
Menu::DrawThemedWindow(dialogDisplayPos,{game->GetScreenSize().x-48.f,20.f});
vf2d speakerTextSize=game->GetTextSizeProp(speakerDisplayName);
@ -231,7 +241,9 @@ LocationCommand::LocationCommand(std::string location)
CommandType::CommandType LocationCommand::GetType(){return CommandType::LOCATION;}
void BackgroundCommand::Execute(VisualNovel&vn){
vn.prevBackgroundFilename=vn.backgroundFilename;
vn.backgroundFilename=backgroundFilename;
vn.transitionTime=2.0f;
vn.ExecuteNextCommand();
}
BackgroundCommand::BackgroundCommand(std::string backgroundFilename)

@ -137,6 +137,7 @@ class VisualNovel{
std::string backgroundFilename;
std::string prevBackgroundFilename;
float transitionTime=0;
static constexpr float maxTransitionTime=2.0f;
std::vector<Command*>commands;
int commandIndex=0;
std::string locationDisplayText="";

@ -106,13 +106,13 @@ What shall I do. I can't return to the Kingdom without it.
[You]
First you should rest. Once you are able to walk on your own again, we can think about a solution for your lost object.
{BACKGROUND sea.png}
{BACKGROUND rest.png}
[]
You set up a tent and a campfire a little outside of the main camp where the tragedy happened and help Sherman to move over.
Without the corpses surrounding you, you relax a little bit. For the rest of the day you keep an Eye on Sherman while he recovers.
{BACKGROUND sea.png}
The next day Sherman no longer lying down, instead sitting on the grass.
[Sherman]

Loading…
Cancel
Save