diff --git a/olcCodeJam2023Entry/Level.h b/olcCodeJam2023Entry/Level.h index badf592..7be9b4a 100644 --- a/olcCodeJam2023Entry/Level.h +++ b/olcCodeJam2023Entry/Level.h @@ -3,8 +3,6 @@ #include "Unit.h" #include "CollectionPoint.h" -class Scenario; - enum LevelName{ STAGE1, STAGE2, diff --git a/olcCodeJam2023Entry/Textbox.cpp b/olcCodeJam2023Entry/Textbox.cpp index d890bb3..750c616 100644 --- a/olcCodeJam2023Entry/Textbox.cpp +++ b/olcCodeJam2023Entry/Textbox.cpp @@ -16,6 +16,7 @@ void Textbox::Initialize(std::string text,vf2d pos,std::string headerText,Render this->boxImg=boxImg; if(this->dialogSound!=nullptr){ this->dialogSound->Stop(soundHandle); + this->dialogSound=nullptr; } if(dialogSound!=nullptr){ this->dialogSound=dialogSound; @@ -133,14 +134,14 @@ void Textbox::Draw(PixelGameEngine*pge,Resources&resources,std::vectorFillRectDecal(boundingRect.pos,maxSize+vf2d{6,6},backCol); pge->DrawRectDecal(boundingRect.pos+vf2d{1,1},maxSize+vf2d{4,4},WHITE); - pge->DrawDecal(boundingRect.pos+vf2d{3,3},IMAGES[MATRIX]->Decal(),{0.375,0.375},DARK_GREY); if(boxImg!=nullptr){ + pge->DrawDecal(boundingRect.pos+vf2d{3,3},IMAGES[MATRIX]->Decal(),{0.375,0.375},DARK_GREY); pge->DrawDecal(boundingRect.pos+vf2d{3,3},boxImg->Decal()); + pge->DrawRectDecal(boundingRect.pos+vf2d{3,3},{24,24},YELLOW); } - pge->DrawRectDecal(boundingRect.pos+vf2d{3,3},{24,24},YELLOW); pge->DrawShadowStringPropDecal(textboxRect.pos+vf2d{3,3},displayHeaderText,{245, 218, 66}); pge->DrawShadowStringPropDecal(textboxRect.pos+vf2d{3.f,float(3+pge->GetTextSizeProp(displayHeaderText).y)},displayText,{220,220,220}); - if(textboxMarker==int(text.length()-1)){ + if(textboxMarker==int(text.length()-1)&&boxImg!=nullptr){ std::string continueText="Click to Continue"; pge->DrawShadowStringPropDecal(textboxRect.pos+textboxRect.size-vf2d(pge->GetTextSizeProp(continueText))*vf2d{0.6,1}-vf2d{5,-9},continueText,{255,255,255,uint8_t(abs(sin(2*continueWordTimer))*255)},{0,0,0,uint8_t(abs(sin(2*continueWordTimer))*255)},{0.6,1}); } diff --git a/olcCodeJam2023Entry/VirusAttack.cpp b/olcCodeJam2023Entry/VirusAttack.cpp index 41fc7d7..741c009 100644 --- a/olcCodeJam2023Entry/VirusAttack.cpp +++ b/olcCodeJam2023Entry/VirusAttack.cpp @@ -555,7 +555,7 @@ void VirusAttack::HandlePanAndZoom(float fElapsedTime){ float speedScale=std::min(1.f,gametv.GetWorldScale().x); bool canMouseScroll=!memoryAllocatorBox.IsVisible()&&!unitCreationBox.IsVisible()&& (GetMouseY()<=ScreenHeight()-64||GetMouseX()<=ScreenWidth()-64 - ||GetMouseScreenX()>=GetWindowPos().x+GetWindowSize().x||GetMouseScreenY()>=GetWindowPos().y+GetWindowSize().y); + ||GetMouseScreenX()>=GetWindowPos().x+GetWindowSize().x||GetMouseScreenY()>=GetWindowPos().y+GetWindowSize().y)&&!restartBox.IsVisible(); if(GetKey(A).bHeld||canMouseScroll&&GetMouseScreenX()<=GetWindowPos().x+CONSTANT::SCROLL_BOUNDARY){ vf2d amt=vf2d{-300*fElapsedTime,0}/speedScale; gametv.MoveWorldOffset(amt); @@ -884,6 +884,10 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ testBox.UpdateAndDraw(GetMousePos()-testBox.GetSize()/2,this,player_resources,IMAGES,GetTotalUsedMemory(),currentLevel->availableMemory); memoryAllocatorBox.UpdateAndDraw(GetMousePos()+vi2d{8,-28},this,player_resources,IMAGES,GetTotalUsedMemory(),currentLevel->availableMemory); platformCreationBox.UpdateAndDraw(GetMousePos()+vi2d{8,-28},this,player_resources,IMAGES,GetTotalUsedMemory(),currentLevel->availableMemory); + restartBox.UpdateAndDraw(GetMousePos()+vf2d{0,10},this,player_resources,IMAGES,GetTotalUsedMemory(),currentLevel->availableMemory); + if(restartButtonHoldTime>0){ + FillRectDecal(restartButton->vPos+vf2d{3,(1-(restartButtonHoldTime/2.5f))*restartButton->vSize.y},{restartButton->vSize.x,((restartButtonHoldTime/2.5f))*restartButton->vSize.y},{255,255,255,128}); + } std::sort(units.begin(),units.end(),[&](auto&u1,auto&u2){ float dist1=geom2d::line(u1->GetGhostPos(),GetWorldMousePos()).length(); @@ -1160,7 +1164,6 @@ void VirusAttack::CalculateUsedMemory(){ } bool VirusAttack::OnUserDestroy(){ - std::for_each(scenarios.begin(),scenarios.end(),[](auto&scenario){delete scenario;}); return true; } @@ -1188,6 +1191,11 @@ void VirusAttack::HandleRestartButton(float fElapsedTime){ if(restartButton->bPressed){ restartButtonHeldDown=true; } + if(restartButton->bReleased){ + restartBox.SetVisible(false); + restartButtonHeldDown=false; + restartButtonHoldTime=0; + } if(restartButtonHeldDown){ restartButtonHoldTime+=fElapsedTime; if(restartButtonHoldTime>=CONSTANT::RESTART_BUTTON_HOLD_TIME){ diff --git a/olcCodeJam2023Entry/VirusAttack.h b/olcCodeJam2023Entry/VirusAttack.h index 4258376..71fd664 100644 --- a/olcCodeJam2023Entry/VirusAttack.h +++ b/olcCodeJam2023Entry/VirusAttack.h @@ -26,15 +26,6 @@ struct Letter{ class VirusAttack : public olc::PixelGameEngine { - friend class Scenario; - friend class Stage1; - friend class Stage2; - friend class Stage3; - friend class Stage4; - friend class Stage5; - friend class Stage6; - friend class Stage7; - friend class Stage8; private: #ifdef SPLASH_ENABLED SplashScreen splash; @@ -47,7 +38,6 @@ private: std::vector>deathAnimations; std::vectordebuffIcons; std::vectorresourceGainIcons; - std::vectorscenarios; olcPGEX_AudioListener AL; Audio*bgm=nullptr; @@ -106,7 +96,7 @@ private: bool reloadLevel=false; bool restartButtonHeldDown=false; float restartButtonHoldTime=0; - GameState state=GameState::GAMEPLAY; + GameState state=GameState::MAIN_MENU; float nextColorChange=10; std::arraycolorChangeOptions={VERY_DARK_BLUE,VERY_DARK_CYAN,VERY_DARK_GREEN,VERY_DARK_GREY,VERY_DARK_MAGENTA,VERY_DARK_RED,VERY_DARK_YELLOW}; Pixel currentBackCol;