mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-21 17:24:37 -05:00
29 lines
632 B
C++
29 lines
632 B
C++
#include "appstates/FadeInState.hpp"
|
|
|
|
#include "StateManager.hpp"
|
|
#include "sdl.hpp"
|
|
|
|
FadeInState::FadeInState(std::shared_ptr<BaseState> nextState)
|
|
: m_nextState{nextState}
|
|
{
|
|
m_fadeTimer.start(1);
|
|
}
|
|
|
|
void FadeInState::update()
|
|
{
|
|
if (m_alpha == 0x00)
|
|
{
|
|
StateManager::push_state(m_nextState);
|
|
BaseState::deactivate();
|
|
}
|
|
else if (m_fadeTimer.is_triggered()) { m_alpha -= 15; }
|
|
}
|
|
|
|
void FadeInState::render()
|
|
{
|
|
m_nextState->render();
|
|
const uint32_t rawColor = 0x000000 | m_alpha;
|
|
const sdl::Color fadeColor{rawColor};
|
|
sdl::render_rect_fill(nullptr, 0, 0, 1280, 720, fadeColor);
|
|
}
|