diff --git a/olcCodeJam2023Entry/Level.h b/olcCodeJam2023Entry/Level.h index 3f58e1c..67a4e28 100644 --- a/olcCodeJam2023Entry/Level.h +++ b/olcCodeJam2023Entry/Level.h @@ -3,6 +3,8 @@ #include "Unit.h" #include "CollectionPoint.h" +class Scenario; + enum LevelName{ STAGE1, STAGE2, @@ -37,6 +39,7 @@ struct Level{ std::vectorunitPlacement; std::vectorcpPlacement; Sound bgm=Sound::COSMOS; + Scenario*scenario; vf2d cameraStart={96,96}; vf2d worldZoom={1,1}; Pixel levelColor=DARK_GREEN; diff --git a/olcCodeJam2023Entry/Scenario.cpp b/olcCodeJam2023Entry/Scenario.cpp new file mode 100644 index 0000000..a45907d --- /dev/null +++ b/olcCodeJam2023Entry/Scenario.cpp @@ -0,0 +1,22 @@ +#include "Scenario.h" + +Scenario::Scenario(VirusAttack*game) + :game(game){} + +void Scenario::_Update(){ + Update(); +} +void Scenario::_Draw(){ + Draw(); +} + +Stage1::Stage1(VirusAttack*game) + :Scenario(game){} + + +void Stage1::Update(){ + +} +void Stage1::Draw(){ + +} \ No newline at end of file diff --git a/olcCodeJam2023Entry/Scenario.h b/olcCodeJam2023Entry/Scenario.h new file mode 100644 index 0000000..216f2a4 --- /dev/null +++ b/olcCodeJam2023Entry/Scenario.h @@ -0,0 +1,20 @@ +#pragma once +#include "VirusAttack.h" + +class Scenario{ + VirusAttack*game; +public: + Scenario(VirusAttack*game); + void _Update(); + virtual void Update()=0; + void _Draw(); + virtual void Draw()=0; +protected: +}; + +class Stage1:public Scenario{ +public: + Stage1(VirusAttack*game); + void Update()override; + void Draw()override; +}; \ No newline at end of file diff --git a/olcCodeJam2023Entry/VirusAttack.cpp b/olcCodeJam2023Entry/VirusAttack.cpp index 355f838..77e3df1 100644 --- a/olcCodeJam2023Entry/VirusAttack.cpp +++ b/olcCodeJam2023Entry/VirusAttack.cpp @@ -13,8 +13,7 @@ #include "olcUTIL_Geometry2D.h" #include "TileManager.h" #include "util.h" - -#include "VirusAttack.h" +#include "Scenario.h" VirusAttack::VirusAttack() { @@ -72,6 +71,7 @@ void VirusAttack::InitializeLevelData(){ LevelName stage=STAGE1; levelData[stage].cameraStart={96,96}; levelData[stage].worldZoom={1,1}; + levelData[stage].scenario=scenarios[0]; levelData[stage].levelColor=DARK_RED; levelData[stage].size={64,64}; levelData[stage].bgm=Sound::BOSS2; @@ -112,6 +112,7 @@ void VirusAttack::InitializeLevelData(){ levelData[stage].cameraStart={96,96}; levelData[stage].worldZoom={1,1}; levelData[stage].size={16,16}; + levelData[stage].scenario=scenarios[1]; levelData[stage].levelColor=DARK_GREEN; levelData[stage].bgm=Sound::COSMOS; levelData[stage].player_starting_resources={10,10,10,10,10}; @@ -155,6 +156,7 @@ bool VirusAttack::OnUserCreate(){ InitializeSounds(); InitializeGUIs(); + InitializeScenarios(); InitializeLevelData(); LoadLevel(STAGE1); @@ -243,6 +245,11 @@ void VirusAttack::InitializeGUIs(){ memoryGuardButton=new QuickGUI::ImageButton(platformCreationList,*IMAGES[MEMORY_GUARD],{0.25,0.25},{float(ScreenWidth()-48),48.f+32*3},{20,20}); } +void VirusAttack::InitializeScenarios(){ + scenarios.emplace_back(new Stage1(this)); + scenarios.emplace_back(new Stage1(this)); +} + void VirusAttack::InitializeSounds(){ int soundIndex=0; auto LoadSound=[&](Sound sound,std::string soundFilename){ @@ -654,6 +661,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ HandleRightClickMove(); HandlePanAndZoom(fElapsedTime); HandleMinimapClick(); + currentLevel->scenario->_Update(); AL.vecPos=game.ScreenToWorld(GetScreenSize()/2); AL.fSoundFXVolume=std::min(1.f,game.GetWorldScale().x); AL.OnUserUpdate(fElapsedTime); @@ -765,6 +773,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ DrawResourceBar(fElapsedTime); DrawDecal({float(ScreenWidth()-74-IMAGES[GUIDE]->Sprite()->width*0.75),float(ScreenHeight()+6-IMAGES[GUIDE]->Sprite()->height*0.75)},IMAGES[GUIDE]->Decal(),{0.75,0.75}); DrawMinimap(); + currentLevel->scenario->_Draw(); unitCreationBox.UpdateAndDraw(GetMousePos()+vi2d{8,-28},this,player_resources,IMAGES); testBox.UpdateAndDraw(GetMousePos()-testBox.GetSize()/2,this,player_resources,IMAGES); @@ -1030,6 +1039,11 @@ void VirusAttack::CalculateUsedMemory(){ } } +bool VirusAttack::OnUserDestroy(){ + std::for_each(scenarios.begin(),scenarios.end(),[](auto&scenario){delete scenario;}); + return true; +} + int main() { VirusAttack app; diff --git a/olcCodeJam2023Entry/VirusAttack.h b/olcCodeJam2023Entry/VirusAttack.h index 2b441ff..615fb49 100644 --- a/olcCodeJam2023Entry/VirusAttack.h +++ b/olcCodeJam2023Entry/VirusAttack.h @@ -1,3 +1,4 @@ +#pragma once #include "olcPixelGameEngine.h" #include "olcSoundWaveEngine.h" #include "olcPGEX_TransformedView.h" @@ -15,6 +16,8 @@ #include "Textbox.h" #include "Level.h" +class Scenario; + struct Letter{ vf2d pos; float spd; @@ -35,6 +38,7 @@ private: std::vector>deathAnimations; std::vectordebuffIcons; std::vectorresourceGainIcons; + std::vectorscenarios; std::map>IMAGES; std::map>SOUNDS; @@ -111,6 +115,7 @@ private: int GetEnemyUsedMemory(); void DrawSystemMemoryBar(float fElapsedTime); void CalculateUsedMemory(); + void InitializeScenarios(); public: VirusAttack(); @@ -119,4 +124,5 @@ public: bool OnUserCreate() override; bool OnUserUpdate(float fElapsedTime) override; + bool OnUserDestroy() override; }; \ No newline at end of file diff --git a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj index 7283692..276be5d 100644 --- a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj +++ b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj @@ -159,6 +159,7 @@ + @@ -171,6 +172,7 @@ + diff --git a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters index cc5fe97..cc833b1 100644 --- a/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters +++ b/olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters @@ -96,6 +96,9 @@ Header Files + + Header Files + @@ -125,6 +128,9 @@ Source Files + + Source Files +