Setup class config file directory structure

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/28/head
Nic0Nic0Nii 1 year ago
parent 1e08589403
commit 3cb8c43da1
  1. 18
      Crawler/Crawler.cpp
  2. 19
      Crawler/Crawler.h
  3. 6
      Crawler/Player.h
  4. 32
      Crawler/Ranger.cpp
  5. 32
      Crawler/Thief.cpp
  6. 32
      Crawler/Trapper.cpp
  7. 32
      Crawler/Warrior.cpp
  8. 32
      Crawler/Witch.cpp
  9. 32
      Crawler/Wizard.cpp
  10. 4
      Crawler/assets/config/classes/Ranger.txt
  11. 4
      Crawler/assets/config/classes/Thief.txt
  12. 4
      Crawler/assets/config/classes/Trapper.txt
  13. 9
      Crawler/assets/config/classes/Warrior.txt
  14. 4
      Crawler/assets/config/classes/Witch.txt
  15. 4
      Crawler/assets/config/classes/Wizard.txt
  16. 6
      Crawler/assets/config/configuration.txt
  17. 20
      Crawler/config.h

@ -14,6 +14,7 @@
#include <set> #include <set>
#include <queue> #include <queue>
#include "Emitter.h" #include "Emitter.h"
#include "config.h"
INCLUDE_EMITTER_LIST INCLUDE_EMITTER_LIST
@ -50,6 +51,13 @@ Crawler::Crawler()
std::string MAP_CONFIG = CONFIG_PATH + "map_config"_S; std::string MAP_CONFIG = CONFIG_PATH + "map_config"_S;
utils::datafile::Read(DATA,MAP_CONFIG); utils::datafile::Read(DATA,MAP_CONFIG);
for(std::string&cl:DATA.GetProperty("class_list").GetValues()){
std::cout<<cl<<std::endl;
utils::datafile::Read(DATA,CONFIG_PATH + "class_directory"_S + cl + ".txt");
}
std::cout<<"Warrior.Right Click Ability.testNumber"_I<<std::endl;
} }
bool Crawler::OnUserCreate(){ bool Crawler::OnUserCreate(){
@ -115,7 +123,7 @@ bool Crawler::OnUserCreate(){
view=TileTransformedView{GetScreenSize(),{1,1}}; view=TileTransformedView{GetScreenSize(),{1,1}};
LoadLevel(CAMPAIGN_1_1); LoadLevel(CAMPAIGN_1_1);
InitializeClassAbilities(); InitializeClasses();
ChangePlayerClass(WARRIOR); ChangePlayerClass(WARRIOR);
Warrior::ability4=Ranger::ability1; //Class ability swapping demonstration. Warrior::ability4=Ranger::ability1; //Class ability swapping demonstration.
@ -1098,7 +1106,13 @@ void Crawler::ChangePlayerClass(Class cl){
GetPlayer()->UpdateIdleAnimation(DOWN); GetPlayer()->UpdateIdleAnimation(DOWN);
} }
void Crawler::InitializeClassAbilities(){ void Crawler::InitializeClasses(){
Warrior::Initialize();
Thief::Initialize();
Ranger::Initialize();
Trapper::Initialize();
Wizard::Initialize();
Witch::Initialize();
Warrior::InitializeClassAbilities(); Warrior::InitializeClassAbilities();
Thief::InitializeClassAbilities(); Thief::InitializeClassAbilities();
Ranger::InitializeClassAbilities(); Ranger::InitializeClassAbilities();

@ -51,7 +51,7 @@ private:
std::vector<TileGroup>upperForegroundTileGroups; std::vector<TileGroup>upperForegroundTileGroups;
int bridgeLayerIndex=-1; int bridgeLayerIndex=-1;
float bridgeFadeFactor=0.f; float bridgeFadeFactor=0.f;
void InitializeClassAbilities(); void InitializeClasses();
public: public:
Crawler(); Crawler();
bool OnUserCreate() override; bool OnUserCreate() override;
@ -108,20 +108,3 @@ public:
double GetDouble(std::string key); double GetDouble(std::string key);
datafiledoubledata GetDoubleList(std::string key); datafiledoubledata GetDoubleList(std::string key);
}; };
//Read a string array from the config.
datafilestringdata operator ""_s(const char*key,std::size_t len);
//Read an int array from the config.
datafileintdata operator ""_i(const char*key,std::size_t len);
//Read a float array from the config.
datafilefloatdata operator ""_f(const char*key,std::size_t len);
//Read a double array from the config.
datafiledoubledata operator ""_d(const char*key,std::size_t len);
//Read a string key from the config.
std::string operator ""_S(const char*key,std::size_t len);
//Read an integer key from the config.
int operator ""_I(const char*key,std::size_t len);
//Read a float key from the config.
float operator ""_F(const char*key,std::size_t len);
//Read a double key from the config.
double operator ""_D(const char*key,std::size_t len);

@ -166,6 +166,7 @@ struct Warrior:Player{
static Class cl; static Class cl;
static Ability rightClickAbility,ability1,ability2,ability3,ability4; static Ability rightClickAbility,ability1,ability2,ability3,ability4;
static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w;
static void Initialize();
Warrior(); Warrior();
Warrior(Player*player); Warrior(Player*player);
Class GetClass()override; Class GetClass()override;
@ -194,6 +195,7 @@ struct Thief:Player{
static Class cl; static Class cl;
static Ability rightClickAbility,ability1,ability2,ability3,ability4; static Ability rightClickAbility,ability1,ability2,ability3,ability4;
static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w;
static void Initialize();
Thief(); Thief();
Thief(Player*player); Thief(Player*player);
Class GetClass()override; Class GetClass()override;
@ -222,6 +224,7 @@ struct Ranger:Player{
static Class cl; static Class cl;
static Ability rightClickAbility,ability1,ability2,ability3,ability4; static Ability rightClickAbility,ability1,ability2,ability3,ability4;
static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w;
static void Initialize();
Ranger(); Ranger();
Ranger(Player*player); Ranger(Player*player);
Class GetClass()override; Class GetClass()override;
@ -250,6 +253,7 @@ struct Trapper:Player{
static Class cl; static Class cl;
static Ability rightClickAbility,ability1,ability2,ability3,ability4; static Ability rightClickAbility,ability1,ability2,ability3,ability4;
static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w;
static void Initialize();
Trapper(); Trapper();
Trapper(Player*player); Trapper(Player*player);
Class GetClass()override; Class GetClass()override;
@ -278,6 +282,7 @@ struct Wizard:Player{
static Class cl; static Class cl;
static Ability rightClickAbility,ability1,ability2,ability3,ability4; static Ability rightClickAbility,ability1,ability2,ability3,ability4;
static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w;
static void Initialize();
Wizard(); Wizard();
Wizard(Player*player); Wizard(Player*player);
Class GetClass()override; Class GetClass()override;
@ -306,6 +311,7 @@ struct Witch:Player{
static Class cl; static Class cl;
static Ability rightClickAbility,ability1,ability2,ability3,ability4; static Ability rightClickAbility,ability1,ability2,ability3,ability4;
static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w;
static void Initialize();
Witch(); Witch();
Witch(Player*player); Witch(Player*player);
Class GetClass()override; Class GetClass()override;

@ -11,21 +11,23 @@ INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST
INCLUDE_game INCLUDE_game
std::string Ranger::name="Ranger"; void Ranger::Initialize(){
Class Ranger::cl=RANGER; Ranger::name="Ranger";
Ability Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE); Ranger::cl=RANGER;
Ability Ranger::ability1=Ability("Rapid Fire",12,35); Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE);
Ability Ranger::ability2=Ability("Charged Shot",15,40,VERY_DARK_RED,DARK_RED,PrecastData(0.3)); Ranger::ability1=Ability("Rapid Fire",12,35);
Ability Ranger::ability3=Ability("Multishot",25,50); Ranger::ability2=Ability("Charged Shot",15,40,VERY_DARK_RED,DARK_RED,PrecastData(0.3));
Ability Ranger::ability4=Ability("???",0,0); Ranger::ability3=Ability("Multishot",25,50);
AnimationState Ranger::idle_n=RANGER_IDLE_N; Ranger::ability4=Ability("???",0,0);
AnimationState Ranger::idle_e=RANGER_IDLE_E; Ranger::idle_n=RANGER_IDLE_N;
AnimationState Ranger::idle_s=RANGER_IDLE_S; Ranger::idle_e=RANGER_IDLE_E;
AnimationState Ranger::idle_w=RANGER_IDLE_W; Ranger::idle_s=RANGER_IDLE_S;
AnimationState Ranger::walk_n=RANGER_WALK_N; Ranger::idle_w=RANGER_IDLE_W;
AnimationState Ranger::walk_e=RANGER_WALK_E; Ranger::walk_n=RANGER_WALK_N;
AnimationState Ranger::walk_s=RANGER_WALK_S; Ranger::walk_e=RANGER_WALK_E;
AnimationState Ranger::walk_w=RANGER_WALK_W; Ranger::walk_s=RANGER_WALK_S;
Ranger::walk_w=RANGER_WALK_W;
}
SETUP_CLASS(Ranger) SETUP_CLASS(Ranger)

@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST
INCLUDE_game INCLUDE_game
std::string Thief::name="Thief"; void Thief::Initialize(){
Class Thief::cl=THIEF; Thief::name="Thief";
Ability Thief::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; Thief::cl=THIEF;
Ability Thief::ability1={"???",12,40}; Thief::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE};
Ability Thief::ability2={"???",15,50}; Thief::ability1={"???",12,40};
Ability Thief::ability3={"???",40,60}; Thief::ability2={"???",15,50};
Ability Thief::ability4={"???",0,0}; Thief::ability3={"???",40,60};
AnimationState Thief::idle_n=WARRIOR_IDLE_N; Thief::ability4={"???",0,0};
AnimationState Thief::idle_e=WARRIOR_IDLE_E; Thief::idle_n=WARRIOR_IDLE_N;
AnimationState Thief::idle_s=WARRIOR_IDLE_S; Thief::idle_e=WARRIOR_IDLE_E;
AnimationState Thief::idle_w=WARRIOR_IDLE_W; Thief::idle_s=WARRIOR_IDLE_S;
AnimationState Thief::walk_n=WARRIOR_WALK_N; Thief::idle_w=WARRIOR_IDLE_W;
AnimationState Thief::walk_e=WARRIOR_WALK_E; Thief::walk_n=WARRIOR_WALK_N;
AnimationState Thief::walk_s=WARRIOR_WALK_S; Thief::walk_e=WARRIOR_WALK_E;
AnimationState Thief::walk_w=WARRIOR_WALK_W; Thief::walk_s=WARRIOR_WALK_S;
Thief::walk_w=WARRIOR_WALK_W;
}
SETUP_CLASS(Thief) SETUP_CLASS(Thief)

@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST
INCLUDE_game INCLUDE_game
std::string Trapper::name="Trapper"; void Trapper::Initialize(){
Class Trapper::cl=TRAPPER; Trapper::name="Trapper";
Ability Trapper::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; Trapper::cl=TRAPPER;
Ability Trapper::ability1={"???",12,40}; Trapper::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE};
Ability Trapper::ability2={"???",15,50}; Trapper::ability1={"???",12,40};
Ability Trapper::ability3={"???",40,60}; Trapper::ability2={"???",15,50};
Ability Trapper::ability4={"???",0,0}; Trapper::ability3={"???",40,60};
AnimationState Trapper::idle_n=WARRIOR_IDLE_N; Trapper::ability4={"???",0,0};
AnimationState Trapper::idle_e=WARRIOR_IDLE_E; Trapper::idle_n=WARRIOR_IDLE_N;
AnimationState Trapper::idle_s=WARRIOR_IDLE_S; Trapper::idle_e=WARRIOR_IDLE_E;
AnimationState Trapper::idle_w=WARRIOR_IDLE_W; Trapper::idle_s=WARRIOR_IDLE_S;
AnimationState Trapper::walk_n=WARRIOR_WALK_N; Trapper::idle_w=WARRIOR_IDLE_W;
AnimationState Trapper::walk_e=WARRIOR_WALK_E; Trapper::walk_n=WARRIOR_WALK_N;
AnimationState Trapper::walk_s=WARRIOR_WALK_S; Trapper::walk_e=WARRIOR_WALK_E;
AnimationState Trapper::walk_w=WARRIOR_WALK_W; Trapper::walk_s=WARRIOR_WALK_S;
Trapper::walk_w=WARRIOR_WALK_W;
}
SETUP_CLASS(Trapper) SETUP_CLASS(Trapper)

@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST
INCLUDE_game INCLUDE_game
std::string Warrior::name="Warrior"; void Warrior::Initialize(){
Class Warrior::cl=WARRIOR; Warrior::name="Warrior";
Ability Warrior::rightClickAbility={"Block",15,0,VERY_DARK_BLUE,DARK_BLUE}; Warrior::cl=WARRIOR;
Ability Warrior::ability1={"Battlecry",12,40}; Warrior::rightClickAbility={"Block",15,0,VERY_DARK_BLUE,DARK_BLUE};
Ability Warrior::ability2={"Ground Slam",15,50}; Warrior::ability1={"Battlecry",12,40};
Ability Warrior::ability3={"Sonic Slash",40,60}; Warrior::ability2={"Ground Slam",15,50};
Ability Warrior::ability4={"???",0,0}; Warrior::ability3={"Sonic Slash",40,60};
AnimationState Warrior::idle_n=WARRIOR_IDLE_N; Warrior::ability4={"???",0,0};
AnimationState Warrior::idle_e=WARRIOR_IDLE_E; Warrior::idle_n=WARRIOR_IDLE_N;
AnimationState Warrior::idle_s=WARRIOR_IDLE_S; Warrior::idle_e=WARRIOR_IDLE_E;
AnimationState Warrior::idle_w=WARRIOR_IDLE_W; Warrior::idle_s=WARRIOR_IDLE_S;
AnimationState Warrior::walk_n=WARRIOR_WALK_N; Warrior::idle_w=WARRIOR_IDLE_W;
AnimationState Warrior::walk_e=WARRIOR_WALK_E; Warrior::walk_n=WARRIOR_WALK_N;
AnimationState Warrior::walk_s=WARRIOR_WALK_S; Warrior::walk_e=WARRIOR_WALK_E;
AnimationState Warrior::walk_w=WARRIOR_WALK_W; Warrior::walk_s=WARRIOR_WALK_S;
Warrior::walk_w=WARRIOR_WALK_W;
}
SETUP_CLASS(Warrior) SETUP_CLASS(Warrior)

@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST
INCLUDE_game INCLUDE_game
std::string Witch::name="Witch"; void Witch::Initialize(){
Class Witch::cl=WITCH; Witch::name="Witch";
Ability Witch::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; Witch::cl=WITCH;
Ability Witch::ability1={"???",12,40}; Witch::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE};
Ability Witch::ability2={"???",15,50}; Witch::ability1={"???",12,40};
Ability Witch::ability3={"???",40,60}; Witch::ability2={"???",15,50};
Ability Witch::ability4={"???",0,0}; Witch::ability3={"???",40,60};
AnimationState Witch::idle_n=WARRIOR_IDLE_N; Witch::ability4={"???",0,0};
AnimationState Witch::idle_e=WARRIOR_IDLE_E; Witch::idle_n=WARRIOR_IDLE_N;
AnimationState Witch::idle_s=WARRIOR_IDLE_S; Witch::idle_e=WARRIOR_IDLE_E;
AnimationState Witch::idle_w=WARRIOR_IDLE_W; Witch::idle_s=WARRIOR_IDLE_S;
AnimationState Witch::walk_n=WARRIOR_WALK_N; Witch::idle_w=WARRIOR_IDLE_W;
AnimationState Witch::walk_e=WARRIOR_WALK_E; Witch::walk_n=WARRIOR_WALK_N;
AnimationState Witch::walk_s=WARRIOR_WALK_S; Witch::walk_e=WARRIOR_WALK_E;
AnimationState Witch::walk_w=WARRIOR_WALK_W; Witch::walk_s=WARRIOR_WALK_S;
Witch::walk_w=WARRIOR_WALK_W;
}
SETUP_CLASS(Witch) SETUP_CLASS(Witch)

@ -10,21 +10,23 @@ INCLUDE_MONSTER_LIST
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST
INCLUDE_game INCLUDE_game
std::string Wizard::name="Wizard"; void Wizard::Initialize(){
Class Wizard::cl=WIZARD; Wizard::name="Wizard";
Ability Wizard::rightClickAbility={"Teleport",8,5,VERY_DARK_BLUE,DARK_BLUE}; Wizard::cl=WIZARD;
Ability Wizard::ability1={"Firebolt",6,30}; Wizard::rightClickAbility={"Teleport",8,5,VERY_DARK_BLUE,DARK_BLUE};
Ability Wizard::ability2={"Lightning Bolt",6,25}; Wizard::ability1={"Firebolt",6,30};
Ability Wizard::ability3={"Meteor",40,75,VERY_DARK_RED,VERY_DARK_RED,PrecastData(1.5,9*24,4*24)}; Wizard::ability2={"Lightning Bolt",6,25};
Ability Wizard::ability4={"???",0,0}; Wizard::ability3={"Meteor",40,75,VERY_DARK_RED,VERY_DARK_RED,PrecastData(1.5,9*24,4*24)};
AnimationState Wizard::idle_n=WIZARD_IDLE_N; Wizard::ability4={"???",0,0};
AnimationState Wizard::idle_e=WIZARD_IDLE_E; Wizard::idle_n=WIZARD_IDLE_N;
AnimationState Wizard::idle_s=WIZARD_IDLE_S; Wizard::idle_e=WIZARD_IDLE_E;
AnimationState Wizard::idle_w=WIZARD_IDLE_W; Wizard::idle_s=WIZARD_IDLE_S;
AnimationState Wizard::walk_n=WIZARD_WALK_N; Wizard::idle_w=WIZARD_IDLE_W;
AnimationState Wizard::walk_e=WIZARD_WALK_E; Wizard::walk_n=WIZARD_WALK_N;
AnimationState Wizard::walk_s=WIZARD_WALK_S; Wizard::walk_e=WIZARD_WALK_E;
AnimationState Wizard::walk_w=WIZARD_WALK_W; Wizard::walk_s=WIZARD_WALK_S;
Wizard::walk_w=WIZARD_WALK_W;
}
SETUP_CLASS(Wizard) SETUP_CLASS(Wizard)

@ -0,0 +1,9 @@
Warrior
{
ClassName = Warrior
Right Click Ability
{
testNumber = 1
}
}

@ -8,3 +8,9 @@ gfx_config = gfx/gfx.txt
# Map Files Loading Config # Map Files Loading Config
map_config = levels.txt map_config = levels.txt
# Path to class configuration files
class_directory = classes/
# Class list to be loaded into the game.
class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch

@ -0,0 +1,20 @@
#include "olcUTIL_DataFile.h"
using namespace olc;
//Read a string array from the config.
utils::datafilestringdata operator ""_s(const char*key,std::size_t len);
//Read an int array from the config.
utils::datafileintdata operator ""_i(const char*key,std::size_t len);
//Read a float array from the config.
utils::datafilefloatdata operator ""_f(const char*key,std::size_t len);
//Read a double array from the config.
utils::datafiledoubledata operator ""_d(const char*key,std::size_t len);
//Read a string key from the config.
std::string operator ""_S(const char*key,std::size_t len);
//Read an integer key from the config.
int operator ""_I(const char*key,std::size_t len);
//Read a float key from the config.
float operator ""_F(const char*key,std::size_t len);
//Read a double key from the config.
double operator ""_D(const char*key,std::size_t len);
Loading…
Cancel
Save