Populate animation data into map

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/28/head
parent 1924dd7463
commit 11742b61f9
  1. BIN
      Crawler/Crawler
  2. 9
      Crawler/Crawler.cpp
  3. 1
      Crawler/Crawler.h
  4. 1
      Crawler/Map.h
  5. 2
      Crawler/TMXParser.h
  6. 6
      Crawler/TSXParser.h
  7. 1
      Crawler/pixelGameEngine.cpp
  8. 2
      Crawler/sig

Binary file not shown.

@ -22,7 +22,6 @@ INCLUDE_EMITTER_LIST
//360x240
vi2d WINDOW_SIZE={24*15,24*10};
safemap<std::string,Animate2D::FrameSequence>ANIMATION_DATA;
std::map<int,std::vector<std::pair<int,float>>>TILE_ANIMATION_DATA;
std::vector<Monster>MONSTER_LIST;
std::vector<MonsterSpawner>SPAWNER_LIST;
std::vector<std::shared_ptr<DamageNumber>>DAMAGENUMBER_LIST;
@ -73,7 +72,6 @@ Crawler::Crawler()
}
bool Crawler::OnUserCreate(){
InitializeLevels();
player=std::make_unique<Warrior>();
@ -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: "<<MAP_TILESETS["assets/maps/"+baseSourceDir].animationData.size()<<std::endl;
r->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){

@ -38,6 +38,7 @@ public:
static Key KEY_ABILITY3;
static Key KEY_ABILITY4;
static float SIZE_CHANGE_SPEED;
float levelTime;
private:
std::vector<std::unique_ptr<Effect>>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted;
std::map<MapName,Map>MAP_DATA;

@ -20,6 +20,7 @@ struct TilesetData{
std::map<int,XMLTag>upperForegroundTiles;
std::map<int,TileCollisionData>collision;
std::map<int,XMLTag>staircaseTiles;
std::map<int,std::vector<std::pair<int,int>>> animationData;
};
struct TileRenderData{

@ -1,7 +1,7 @@
#pragma once
#include "olcPixelGameEngine.h"
#include "olcUTIL_Geometry2D.h"
#include <strstream>
#include <sstream>
using namespace olc;

@ -1,6 +1,6 @@
#pragma once
#include "olcPixelGameEngine.h"
#include <strstream>
#include <sstream>
#include "TMXParser.h"
#include "Map.h"
#include "olcUTIL_Geometry2D.h"
@ -13,6 +13,7 @@ struct Tileset{
std::map<int,XMLTag> UpperForegroundTileData;
std::map<int,TileCollisionData> CollisionData;
std::map<int,XMLTag> StaircaseData;
std::map<int,std::vector<std::pair<int,int>>> 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="";

@ -1,3 +1,4 @@
//#define OLC_PGE_HEADLESS
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
#define OLC_PGEX_TRANSFORMEDVIEW

@ -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++"

Loading…
Cancel
Save