From cbfcb2793fef5d0bf78b02ccef34760f4416d776 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 19 Aug 2023 11:57:02 -0500 Subject: [PATCH] Player animations now load dynamically from configuration files. --- Crawler/Animation.cpp | 57 +++++------------------------- Crawler/Crawler.cpp | 8 ++++- Crawler/Version.h | 2 +- Crawler/assets/config/Monsters.txt | 5 +-- Crawler/assets/config/Player.txt | 13 +++++++ Crawler/config.h | 2 ++ 6 files changed, 35 insertions(+), 52 deletions(-) diff --git a/Crawler/Animation.cpp b/Crawler/Animation.cpp index 8f76f1b7..87e7e747 100644 --- a/Crawler/Animation.cpp +++ b/Crawler/Animation.cpp @@ -5,6 +5,7 @@ INCLUDE_game INCLUDE_ANIMATION_DATA +INCLUDE_DATA void sig::Animation::InitializeAnimations(){ @@ -208,54 +209,14 @@ void sig::Animation::InitializeAnimations(){ } void sig::Animation::SetupPlayerAnimations(){ - game->GetPlayer()->AddAnimation("WARRIOR_WALK_N"); - game->GetPlayer()->AddAnimation("WARRIOR_WALK_E"); - game->GetPlayer()->AddAnimation("WARRIOR_WALK_S"); - game->GetPlayer()->AddAnimation("WARRIOR_WALK_W"); - game->GetPlayer()->AddAnimation("WARRIOR_IDLE_N"); - game->GetPlayer()->AddAnimation("WARRIOR_IDLE_E"); - game->GetPlayer()->AddAnimation("WARRIOR_IDLE_S"); - game->GetPlayer()->AddAnimation("WARRIOR_IDLE_W"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSWORD_E"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSWORD_S"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSWORD_N"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSWORD_W"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSONICSWORD_E"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSONICSWORD_S"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSONICSWORD_N"); - game->GetPlayer()->AddAnimation("WARRIOR_SWINGSONICSWORD_W"); - game->GetPlayer()->AddAnimation("RANGER_WALK_N"); - game->GetPlayer()->AddAnimation("RANGER_WALK_E"); - game->GetPlayer()->AddAnimation("RANGER_WALK_S"); - game->GetPlayer()->AddAnimation("RANGER_WALK_W"); - game->GetPlayer()->AddAnimation("RANGER_IDLE_N"); - game->GetPlayer()->AddAnimation("RANGER_IDLE_E"); - game->GetPlayer()->AddAnimation("RANGER_IDLE_S"); - game->GetPlayer()->AddAnimation("RANGER_IDLE_W"); - game->GetPlayer()->AddAnimation("RANGER_SHOOT_S"); - game->GetPlayer()->AddAnimation("RANGER_SHOOT_N"); - game->GetPlayer()->AddAnimation("RANGER_SHOOT_W"); - game->GetPlayer()->AddAnimation("RANGER_SHOOT_E"); - game->GetPlayer()->AddAnimation("WIZARD_WALK_N"); - game->GetPlayer()->AddAnimation("WIZARD_WALK_E"); - game->GetPlayer()->AddAnimation("WIZARD_WALK_S"); - game->GetPlayer()->AddAnimation("WIZARD_WALK_W"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_N"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_E"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_S"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_W"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_ATTACK_N"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_ATTACK_E"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_ATTACK_S"); - game->GetPlayer()->AddAnimation("WIZARD_IDLE_ATTACK_W"); - game->GetPlayer()->AddAnimation("WIZARD_ATTACK_N"); - game->GetPlayer()->AddAnimation("WIZARD_ATTACK_E"); - game->GetPlayer()->AddAnimation("WIZARD_ATTACK_S"); - game->GetPlayer()->AddAnimation("WIZARD_ATTACK_W"); - game->GetPlayer()->AddAnimation("WIZARD_CAST_N"); - game->GetPlayer()->AddAnimation("WIZARD_CAST_E"); - game->GetPlayer()->AddAnimation("WIZARD_CAST_S"); - game->GetPlayer()->AddAnimation("WIZARD_CAST_W"); + int counter=0; + while("Player"_A.HasProperty("PLAYER_ANIMATION["+std::to_string(counter)+"]")){ + game->GetPlayer()->AddAnimation(DATA["Player"]["PLAYER_ANIMATION["+std::to_string(counter)+"]"].GetString()+"_N"); + game->GetPlayer()->AddAnimation(DATA["Player"]["PLAYER_ANIMATION["+std::to_string(counter)+"]"].GetString()+"_E"); + game->GetPlayer()->AddAnimation(DATA["Player"]["PLAYER_ANIMATION["+std::to_string(counter)+"]"].GetString()+"_S"); + game->GetPlayer()->AddAnimation(DATA["Player"]["PLAYER_ANIMATION["+std::to_string(counter)+"]"].GetString()+"_W"); + counter++; + } ANIMATION_DATA.SetInitialized(); } \ No newline at end of file diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 20bffd37..fc4412ca 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -1173,7 +1173,6 @@ datafiledoubledata Crawler::GetDoubleList(std::string key){ return {DATA,key}; } - int main() { char*testArr = new char[5000]; @@ -1253,4 +1252,11 @@ double operator ""_D(const char*key,std::size_t len){ std::cout<