generated from sigonasr2/CPlusPlusProjectTemplate
Fade out / in logic
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
bd01a1103d
commit
5048085192
@ -13,6 +13,7 @@ enum GAMESTATE{
|
|||||||
#define HEIGHT 224
|
#define HEIGHT 224
|
||||||
#define ALPHA_SCREEN1 128
|
#define ALPHA_SCREEN1 128
|
||||||
#define ALPHA_SCREEN2 20
|
#define ALPHA_SCREEN2 20
|
||||||
|
#define FADE_SPD 6
|
||||||
|
|
||||||
class SeasonsOfLoneliness : public olc::PixelGameEngine
|
class SeasonsOfLoneliness : public olc::PixelGameEngine
|
||||||
{
|
{
|
||||||
@ -43,7 +44,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetAnyKey() {
|
bool GetAnyKey() {
|
||||||
cout << "Something has changed.";
|
switch (GAME_STATE) {
|
||||||
|
case CUTSCENE_1:{
|
||||||
|
if (textInd>=STORY_TEXT1.length()) {
|
||||||
|
fadeOut();
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
@ -61,11 +68,11 @@ public:
|
|||||||
|
|
||||||
void updateGame(){
|
void updateGame(){
|
||||||
frameCount++;
|
frameCount++;
|
||||||
if (fade&&transparency>0) {
|
if (fade&&transparency<255) {
|
||||||
transparency--;
|
transparency=clamp(transparency+FADE_SPD,0,255);
|
||||||
} else
|
} else
|
||||||
if (!fade&&transparency<255) {
|
if (!fade&&transparency>0) {
|
||||||
transparency++;
|
transparency=clamp(transparency-FADE_SPD,0,255);
|
||||||
}
|
}
|
||||||
switch (GAME_STATE) {
|
switch (GAME_STATE) {
|
||||||
case CUTSCENE_1:{
|
case CUTSCENE_1:{
|
||||||
@ -98,7 +105,6 @@ public:
|
|||||||
|
|
||||||
void drawGame(){
|
void drawGame(){
|
||||||
switch (GAME_STATE) {
|
switch (GAME_STATE) {
|
||||||
FillRectDecal({0,0},{WIDTH,HEIGHT},olc::Pixel(0,0,0,transparency));
|
|
||||||
case CUTSCENE_1:{
|
case CUTSCENE_1:{
|
||||||
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,1});
|
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,1});
|
||||||
if (textInd<STORY_TEXT1.length()) {
|
if (textInd<STORY_TEXT1.length()) {
|
||||||
@ -112,6 +118,7 @@ public:
|
|||||||
GradientFillRectDecal({WIDTH/2,HEIGHT/2},{WIDTH/2,HEIGHT/2},{20, 28, 22,ALPHA_SCREEN2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1});
|
GradientFillRectDecal({WIDTH/2,HEIGHT/2},{WIDTH/2,HEIGHT/2},{20, 28, 22,ALPHA_SCREEN2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1});
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
FillRectDecal({0,0},{WIDTH,HEIGHT},olc::Pixel(0,0,0,transparency));
|
||||||
}
|
}
|
||||||
|
|
||||||
void fadeOut() {
|
void fadeOut() {
|
||||||
|
|||||||
Binary file not shown.
@ -3291,6 +3291,9 @@ namespace olc
|
|||||||
bool PixelGameEngine::OnUserDestroy()
|
bool PixelGameEngine::OnUserDestroy()
|
||||||
{ return true; }
|
{ return true; }
|
||||||
|
|
||||||
|
bool PixelGameEngine::GetAnyKey()
|
||||||
|
{ return false; }
|
||||||
|
|
||||||
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); }
|
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); }
|
||||||
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; }
|
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; }
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user