#pragma once #include "olcPixelGameEngine.h" #include "Animation.h" #include "olcUTIL_Animate2D.h" #include "Monster.h" #include "olcPGEX_TransformedView.h" #include "Player.h" #include "olcUTIL_Camera2D.h" #include "Bullet.h" #include "Effect.h" #include "Map.h" #include "TMXParser.h" #include "olcUTIL_DataFile.h" class Crawler : public olc::PixelGameEngine { friend class sig::Animation; Camera2D camera; std::unique_ptrplayer; Renderable GFX_Warrior_Sheet, GFX_Effect_GroundSlam_Back,GFX_Effect_GroundSlam_Front, GFX_Heart,GFX_BLOCK_BUBBLE,GFX_Ranger_Sheet,GFX_Wizard_Sheet, GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash,GFX_EnergyParticle, GFX_Splash_Effect,GFX_LightningBolt,GFX_LightningBoltParticle1, GFX_LightningBoltParticle2,GFX_LightningBoltParticle3,GFX_LightningBoltParticle4, GFX_ChainLightning,GFX_LightningSplash,GFX_Meteor,GFX_Arrow, GFX_Laser,GFX_ChargedArrow,GFX_RangeIndicator; public: Renderable GFX_BulletCircle,GFX_BulletCircleOutline,GFX_EnergyBolt,GFX_Circle; Pathfinding pathfinder; static Key KEY_ABILITY1; static Key KEY_ABILITY2; static Key KEY_ABILITY3; static Key KEY_ABILITY4; static float SIZE_CHANGE_SPEED; float levelTime; private: std::vector>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted; std::mapMAP_DATA; std::mapMAP_TILESETS; vf2d worldShake={}; float worldShakeTime=0; float lastWorldShakeAdjust=0; vf2d worldShakeVel={}; const float WORLD_SHAKE_ADJUST_MAX_TIME=0.4; MapName currentLevel=MapName::CAMPAIGN_1_1; std::vectorforegroundTileGroups; std::vectorupperForegroundTileGroups; int bridgeLayerIndex=-1; float bridgeFadeFactor=0.f; void InitializeClasses(); int DEBUG_PATHFINDING=0; public: Crawler(); bool OnUserCreate() override; bool OnUserUpdate(float fElapsedTime) override; public: geom2d::rectNO_COLLISION={}; vi2d WORLD_SIZE={120,8}; TileTransformedView view; void InitializeLevel(std::string mapFile,MapName map); void LoadLevel(MapName map); void HandleUserInput(float fElapsedTime); void UpdateCamera(float fElapsedTime); void UpdateEffects(float fElapsedTime); void UpdateBullets(float fElapsedTime); void RenderWorld(float fElapsedTime); void RenderHud(); void AddEffect(std::unique_ptrforeground,std::unique_ptrbackground); //If back is true, places the effect in the background void AddEffect(std::unique_ptrforeground,bool back=false); void HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel,float z); vf2d GetWorldMousePos(); bool LeftHeld(); bool RightHeld(); bool UpHeld(); bool DownHeld(); bool LeftReleased(); bool RightReleased(); bool UpReleased(); bool DownReleased(); Player*GetPlayer(); void SetupWorldShake(float duration); vi2d GetWorldSize(); //tileID is the tile number from the tilesets. bool IsForegroundTile(TilesheetData sheet,int tileID); //tileID is the tile number from the tilesets. bool IsUpperForegroundTile(int tileID); //tileID is the tile number from the tilesets. TilesheetData GetTileSheet(MapName map,int tileID); //Gets the rectangle of the tile collision at this tile. If upperLevel is set to true, the collision tile must be in a Bridge class layer for the tile to hit. Also, zones containing LowerBridgeCollision will apply when upperLevel is set to false. geom2d::rectGetTileCollision(MapName map,vf2d pos,bool upperLevel=false); //Checks if the point resides inside of a collision tile. bool HasTileCollision(MapName map,vf2d pos,bool upperLevel=false); MapName GetCurrentLevel(); bool IsBridgeLayer(LayerTag&layer); std::map>>&GetZoneData(MapName map); void PopulateRenderLists(std::vector&monstersBeforeLower,std::vector&monstersBeforeUpper,std::vector&monstersAfterLower,std::vector&monstersAfterUpper,std::vector&bulletsLower,std::vector&bulletsUpper,std::vector&backgroundEffectsLower,std::vector&backgroundEffectsUpper,std::vector&foregroundEffectsLower,std::vector&foregroundEffectsUpper); void ChangePlayerClass(Class cl); std::string GetString(std::string key); datafilestringdata GetStringList(std::string key); int GetInt(std::string key); datafileintdata GetIntList(std::string key); float GetFloat(std::string key); datafilefloatdata GetFloatList(std::string key); double GetDouble(std::string key); datafiledoubledata GetDoubleList(std::string key); static void OutputDebugInfo(const char*key,std::size_t len); void InitializeLevels(); void RenderTile(vi2d pos,TilesheetData tileSheet,int tileSheetIndex,vi2d tileSheetPos); void RenderTile(TileRenderData&tileSheet,Pixel col); struct TileGroupData{ vi2d tilePos; int layer; bool operator<(const TileGroupData&rhs)const{ return layer