#define OLC_PGE_APPLICATION #define OLC_SOUNDWAVE #define OLC_PGEX_TRANSFORMEDVIEW #define AUDIO_LISTENER_IMPLEMENTATION #define AUDIO_SOURCE_IMPLEMENTATION #include "olcUTIL_Geometry2D.h" #include "TileManager.h" #include "util.h" #include "VirusAttack.h" VirusAttack::VirusAttack() { // Name your application sAppName = "olcCodeJam 2023 Entry"; } void VirusAttack::InitializeImages(){ auto LoadImage=[&](Image img,std::string filepath,bool filter=false,bool clamp=true){ IMAGES[img]=std::make_unique(); IMAGES[img]->Load(filepath,nullptr,filter,clamp); }; LoadImage(TILE,"assets/tile.png",false,false); LoadImage(MINIMAP_HUD,"assets/minimap_hud.png"); LoadImage(OUTLINE,"assets/outline.png"); LoadImage(VIRUS_IMG1,"assets/unit.png"); LoadImage(SELECTION_CIRCLE,"assets/selection_circle.png"); LoadImage(MEMORY_COLLECTION_POINT,"assets/memory_collection_point.png"); LoadImage(LEFT_SHIFTER,"assets/left_shifter.png"); LoadImage(RIGHT_SHIFTER,"assets/right_shifter.png"); LoadImage(BIT_RESTORER,"assets/bit_restorer.png"); LoadImage(MEMORY_SWAPPER,"assets/memory_swapper.png"); LoadImage(CORRUPTER,"assets/corrupter.png"); LoadImage(UNIT_ALLOCATOR,"assets/shell.png"); LoadImage(RAM_BANK,"assets/ram_bank.png"); LoadImage(RANGE_INDICATOR,"assets/range_indicator.png"); LoadImage(DOWN_ARROW,"assets/down_arrow.png"); LoadImage(RED_X,"assets/red_x.png"); LoadImage(RLD,"assets/rld.png"); LoadImage(PRC,"assets/prc.png"); LoadImage(RNG,"assets/rng.png"); LoadImage(SPD,"assets/spd.png"); LoadImage(TARGETING_LINE,"assets/targetLine.png"); LoadImage(ATTACKING_LINE,"assets/attackLine.png"); LoadImage(RLD_ICON,"assets/rld_icon.png"); LoadImage(PRC_ICON,"assets/prc_icon.png"); LoadImage(RNG_ICON,"assets/rng_icon.png"); LoadImage(SPD_ICON,"assets/spd_icon.png"); } bool VirusAttack::OnUserCreate(){ SetPixelMode(Pixel::MASK); game.Initialise(GetScreenSize()); InitializeImages(); IMAGES[MINIMAP_OUTLINE]=std::make_unique(); IMAGES[MINIMAP_OUTLINE]->Create(64,64); IMAGES[MATRIX]=std::make_unique(); IMAGES[MATRIX]->Create(64,64,false,false); IMAGES[MATRIX]->Sprite()->SetSampleMode(Sprite::PERIODIC); AL.AudioSystemInit(); InitializeSounds(); units.push_back(std::make_unique(this,vf2d{128,128},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{129,129},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{130,130},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{130,140},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{131,131},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{132,132},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{133,133},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{134,134},IMAGES,true)); for(int i=0;i<5;i++){ collectionPoints.push_back(std::make_unique(this,vf2d{32.f+48*i,32.f},0,*IMAGES[MEMORY_COLLECTION_POINT],MemoryType(i))); collectionPoints.push_back(std::make_unique(this,vf2d{32.f,32.f+48*i},-PI/2,*IMAGES[MEMORY_COLLECTION_POINT],MemoryType(i))); } units.push_back(std::make_unique(this,vf2d{1200,1200},IMAGES,false)); units.push_back(std::make_unique(this,vf2d{1260,1200},IMAGES,false)); units.push_back(std::make_unique(this,vf2d{360,300},IMAGES,false)); units.push_back(std::make_unique(this,vf2d{361,300},IMAGES,false)); return true; } void VirusAttack::InitializeSounds(){ int soundIndex=0; auto LoadSound=[&](Sound sound,std::string soundFilename){ SOUNDS[sound]=std::make_unique