diff --git a/Crawler/Crawler b/Crawler/Crawler index cf814b54..00b741eb 100755 Binary files a/Crawler/Crawler and b/Crawler/Crawler differ diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 07c3bef3..b03b93d0 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -22,7 +22,6 @@ INCLUDE_EMITTER_LIST //360x240 vi2d WINDOW_SIZE={24*15,24*10}; safemapANIMATION_DATA; -std::map>>TILE_ANIMATION_DATA; std::vectorMONSTER_LIST; std::vectorSPAWNER_LIST; std::vector>DAMAGENUMBER_LIST; @@ -73,7 +72,6 @@ Crawler::Crawler() } bool Crawler::OnUserCreate(){ - InitializeLevels(); player=std::make_unique(); @@ -133,12 +131,12 @@ bool Crawler::OnUserCreate(){ InitializeClasses(); ChangePlayerClass(WARRIOR); Warrior::ability4=Ranger::ability1; //Class ability swapping demonstration. - return true; } bool Crawler::OnUserUpdate(float fElapsedTime){ - fElapsedTime=std::clamp(fElapsedTime,0.f,1/60.f); //HACK fix. We can't have a negative time. Although using a more precise system clock should make this never occur. Also make sure if the game is too slow we advance by only 1/60th of a second. + fElapsedTime=std::clamp(fElapsedTime,0.f,1/30.f); //HACK fix. We can't have a negative time. Although using a more precise system clock should make this never occur. Also make sure if the game is too slow we advance by only 1/30th of a second. + levelTime+=fElapsedTime; HandleUserInput(fElapsedTime); UpdateEffects(fElapsedTime); player->Update(fElapsedTime); @@ -872,6 +870,8 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ MAP_TILESETS["assets/maps/"+baseSourceDir].upperForegroundTiles=tileset.GetData().UpperForegroundTileData; MAP_TILESETS["assets/maps/"+baseSourceDir].collision=tileset.GetData().CollisionData; MAP_TILESETS["assets/maps/"+baseSourceDir].staircaseTiles=tileset.GetData().StaircaseData; + MAP_TILESETS["assets/maps/"+baseSourceDir].animationData=tileset.GetData().AnimationData; + std::cout<<"assets/maps/"+baseSourceDir<<" Animation Data Size: "<Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); } } @@ -882,6 +882,7 @@ void Crawler::LoadLevel(MapName map){ foregroundTileGroups.clear(); currentLevel=map; WORLD_SIZE={MAP_DATA[map].MapData.width,MAP_DATA[map].MapData.height}; + levelTime=0; #pragma region Monster Spawn Data Setup for(auto key:MAP_DATA[map].SpawnerData){ diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 33cc6179..97560918 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -38,6 +38,7 @@ public: 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; diff --git a/Crawler/Map.h b/Crawler/Map.h index 6cebefe9..2a7706d1 100644 --- a/Crawler/Map.h +++ b/Crawler/Map.h @@ -20,6 +20,7 @@ struct TilesetData{ std::mapupperForegroundTiles; std::mapcollision; std::mapstaircaseTiles; + std::map>> animationData; }; struct TileRenderData{ diff --git a/Crawler/TMXParser.h b/Crawler/TMXParser.h index a1f72070..4bcad5e8 100644 --- a/Crawler/TMXParser.h +++ b/Crawler/TMXParser.h @@ -1,7 +1,7 @@ #pragma once #include "olcPixelGameEngine.h" #include "olcUTIL_Geometry2D.h" -#include +#include using namespace olc; diff --git a/Crawler/TSXParser.h b/Crawler/TSXParser.h index 834e562c..d9399072 100644 --- a/Crawler/TSXParser.h +++ b/Crawler/TSXParser.h @@ -1,6 +1,6 @@ #pragma once #include "olcPixelGameEngine.h" -#include +#include #include "TMXParser.h" #include "Map.h" #include "olcUTIL_Geometry2D.h" @@ -13,6 +13,7 @@ struct Tileset{ std::map UpperForegroundTileData; std::map CollisionData; std::map StaircaseData; + std::map>> AnimationData; friend std::ostream& operator << (std::ostream& os, Tileset& rhs); }; @@ -102,6 +103,9 @@ class TSXParser{ previousTag=newTag.tag; previousTagID=newTag.GetInteger("id"); } else + if (newTag.tag=="frame"){ + parsedTilesetInfo.AnimationData[previousTagID].push_back({newTag.GetInteger("tileid"),newTag.GetInteger("duration")}); + } else if (newTag.tag=="property"&&staircaseTag=="tile"){ parsedTilesetInfo.StaircaseData[previousTagID]=newTag; staircaseTag=""; diff --git a/Crawler/pixelGameEngine.cpp b/Crawler/pixelGameEngine.cpp index 8ec83e5d..0ff56113 100644 --- a/Crawler/pixelGameEngine.cpp +++ b/Crawler/pixelGameEngine.cpp @@ -1,3 +1,4 @@ +//#define OLC_PGE_HEADLESS #define OLC_PGE_APPLICATION #include "olcPixelGameEngine.h" #define OLC_PGEX_TRANSFORMEDVIEW diff --git a/Crawler/sig b/Crawler/sig index b851c3a8..0c9e7637 100755 --- a/Crawler/sig +++ b/Crawler/sig @@ -3,7 +3,7 @@ export AUTO_UPDATE=true source utils/define.sh define PROJECT_NAME "Crawler" -define CUSTOM_PARAMS "-std=c++20 -lX11 -lGL -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3" +define CUSTOM_PARAMS "-std=c++20 -lX11 -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3" define EMSCRIPTEN_CUSTOM_PARAMS "-s MAXIMUM_MEMORY=4GB" define LANGUAGE "C++"