Setup Scenario structures.
This commit is contained in:
parent
1074d4a59a
commit
d61b647fda
@ -3,6 +3,8 @@
|
||||
#include "Unit.h"
|
||||
#include "CollectionPoint.h"
|
||||
|
||||
class Scenario;
|
||||
|
||||
enum LevelName{
|
||||
STAGE1,
|
||||
STAGE2,
|
||||
@ -37,6 +39,7 @@ struct Level{
|
||||
std::vector<UnitData>unitPlacement;
|
||||
std::vector<CPData>cpPlacement;
|
||||
Sound bgm=Sound::COSMOS;
|
||||
Scenario*scenario;
|
||||
vf2d cameraStart={96,96};
|
||||
vf2d worldZoom={1,1};
|
||||
Pixel levelColor=DARK_GREEN;
|
||||
|
||||
22
olcCodeJam2023Entry/Scenario.cpp
Normal file
22
olcCodeJam2023Entry/Scenario.cpp
Normal file
@ -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(){
|
||||
|
||||
}
|
||||
20
olcCodeJam2023Entry/Scenario.h
Normal file
20
olcCodeJam2023Entry/Scenario.h
Normal file
@ -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;
|
||||
};
|
||||
@ -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;
|
||||
|
||||
@ -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<std::unique_ptr<DeathAnimation>>deathAnimations;
|
||||
std::vector<DebuffIcon>debuffIcons;
|
||||
std::vector<ResourceGainIcon>resourceGainIcons;
|
||||
std::vector<Scenario*>scenarios;
|
||||
|
||||
std::map<Image,std::unique_ptr<Renderable>>IMAGES;
|
||||
std::map<Sound,std::unique_ptr<Audio>>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;
|
||||
};
|
||||
@ -159,6 +159,7 @@
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="resource1.h" />
|
||||
<ClInclude Include="Resources.h" />
|
||||
<ClInclude Include="Scenario.h" />
|
||||
<ClInclude Include="Sound.h" />
|
||||
<ClInclude Include="Textbox.h" />
|
||||
<ClInclude Include="TileManager.h" />
|
||||
@ -171,6 +172,7 @@
|
||||
<ClCompile Include="Constant.cpp" />
|
||||
<ClCompile Include="DeathAnimations.cpp" />
|
||||
<ClCompile Include="DebuffIcon.cpp" />
|
||||
<ClCompile Include="Scenario.cpp" />
|
||||
<ClCompile Include="Textbox.cpp" />
|
||||
<ClCompile Include="TileManager.cpp" />
|
||||
<ClCompile Include="Unit.cpp" />
|
||||
|
||||
@ -96,6 +96,9 @@
|
||||
<ClInclude Include="Level.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Scenario.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="VirusAttack.cpp">
|
||||
@ -125,6 +128,9 @@
|
||||
<ClCompile Include="Textbox.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Scenario.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="olcCodeJam2023Entry.rc">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user