|
|
@ -39,10 +39,13 @@ All rights reserved. |
|
|
|
#include "DEFINES.h" |
|
|
|
#include "DEFINES.h" |
|
|
|
#include "AdventuresInLestoria.h" |
|
|
|
#include "AdventuresInLestoria.h" |
|
|
|
#include "Overlay.h" |
|
|
|
#include "Overlay.h" |
|
|
|
|
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
|
|
INCLUDE_game |
|
|
|
INCLUDE_game |
|
|
|
INCLUDE_ANIMATION_DATA |
|
|
|
INCLUDE_ANIMATION_DATA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const float Overlay::ALPHA_TIME{0.5f}; |
|
|
|
|
|
|
|
|
|
|
|
Overlay::Overlay(std::string animationName,Pixel overlayCol) |
|
|
|
Overlay::Overlay(std::string animationName,Pixel overlayCol) |
|
|
|
:animationName(animationName),overlayCol(overlayCol){} |
|
|
|
:animationName(animationName),overlayCol(overlayCol){} |
|
|
|
const Pixel&Overlay::GetOverlayCol()const{ |
|
|
|
const Pixel&Overlay::GetOverlayCol()const{ |
|
|
@ -52,15 +55,22 @@ void Overlay::SetOverlayCol(Pixel newOverlayCol){ |
|
|
|
overlayCol=newOverlayCol; |
|
|
|
overlayCol=newOverlayCol; |
|
|
|
} |
|
|
|
} |
|
|
|
void Overlay::Enable(){ |
|
|
|
void Overlay::Enable(){ |
|
|
|
|
|
|
|
alpha=0; |
|
|
|
|
|
|
|
alphaTimer=0.f; |
|
|
|
enabled=true; |
|
|
|
enabled=true; |
|
|
|
} |
|
|
|
} |
|
|
|
void Overlay::Disable(){ |
|
|
|
void Overlay::Disable(){ |
|
|
|
|
|
|
|
alpha=255; |
|
|
|
|
|
|
|
alphaTimer=0.f; |
|
|
|
enabled=false; |
|
|
|
enabled=false; |
|
|
|
} |
|
|
|
} |
|
|
|
void Overlay::Draw(){ |
|
|
|
void Overlay::Draw(){ |
|
|
|
if(!enabled)return; |
|
|
|
alphaTimer+=game->GetElapsedTime(); |
|
|
|
|
|
|
|
if(enabled)alpha=util::lerp(0,255,std::min(1.f,alphaTimer/ALPHA_TIME)); |
|
|
|
|
|
|
|
else alpha=util::lerp(255,0,std::min(1.f,alphaTimer/ALPHA_TIME)); |
|
|
|
|
|
|
|
|
|
|
|
const Animate2D::Frame&animationFrame{ANIMATION_DATA.at(animationName).GetFrame(game->GetRunTime())}; |
|
|
|
const Animate2D::Frame&animationFrame{ANIMATION_DATA.at(animationName).GetFrame(game->GetRunTime())}; |
|
|
|
game->DrawPartialDecal({},animationFrame.GetSourceRect().size,animationFrame.GetSourceImage()->Decal(),animationFrame.GetSourceRect().pos,animationFrame.GetSourceRect().size,overlayCol); |
|
|
|
game->DrawPartialDecal({},animationFrame.GetSourceRect().size,animationFrame.GetSourceImage()->Decal(),animationFrame.GetSourceRect().pos,animationFrame.GetSourceRect().size,{overlayCol.r,overlayCol.g,overlayCol.b,uint8_t(overlayCol.a*uint8_t(alpha/255.f))}); |
|
|
|
} |
|
|
|
} |
|
|
|
void Overlay::Reset(){ |
|
|
|
void Overlay::Reset(){ |
|
|
|
animationName="pixel.png"; |
|
|
|
animationName="pixel.png"; |
|
|
|