From 5173f4f2a9cf45dcfb6b46b8cf204a9046c61d61 Mon Sep 17 00:00:00 2001 From: ProgramSnail Date: Mon, 22 Mar 2021 19:37:34 +0300 Subject: [PATCH] some additional functions --- src/game/map_entities/action.cpp | 0 src/game/map_entities/action.hpp | 9 +++++++++ src/game/map_entities/actions.hpp | 1 + src/game/map_entities/cell.cpp | 1 + src/game/map_entities/cell.hpp | 24 ++++++++++++++++++++++++ src/game/map_entities/unit_obj.cpp | 5 +++++ src/game/map_entities/unit_obj.hpp | 29 +++++++++++++++++++++++++++++ src/game/unit/module_builder.cpp | 5 +++++ src/game/unit/module_builder.hpp | 14 ++++++++++++++ src/game/unit/modules.hpp | 1 + src/game/unit/unit.cpp | 5 +++++ src/game/unit/unit.hpp | 15 +++++++++++++++ src/game/unit/unit_memory.cpp | 0 src/game/unit/unit_memory.hpp | 0 src/game/unit/unit_memory_elem.hpp | 7 +++++++ src/game/unit/unit_module.cpp | 5 +++++ src/game/unit/unit_module.hpp | 17 +++++++++++++++++ src/out_api/draw.cpp | 24 +++--------------------- src/out_api/draw.hpp | 6 +++--- src/out_api/init.cpp | 27 +++++++++++++++++++++++++++ src/out_api/init.hpp | 14 ++++++++++++++ src/out_api/input.cpp | 17 +++++++++++++++++ src/out_api/input.hpp | 12 ++++++++++++ 23 files changed, 214 insertions(+), 24 deletions(-) delete mode 100644 src/game/map_entities/action.cpp delete mode 100644 src/game/unit/unit_memory.cpp delete mode 100644 src/game/unit/unit_memory.hpp create mode 100644 src/game/unit/unit_memory_elem.hpp create mode 100644 src/out_api/init.cpp create mode 100644 src/out_api/init.hpp diff --git a/src/game/map_entities/action.cpp b/src/game/map_entities/action.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/game/map_entities/action.hpp b/src/game/map_entities/action.hpp index e69de29..3fcc16c 100644 --- a/src/game/map_entities/action.hpp +++ b/src/game/map_entities/action.hpp @@ -0,0 +1,9 @@ +#pragma ONCE + +namespace map { + class Action { + private: + public: + void update(); + }; +} \ No newline at end of file diff --git a/src/game/map_entities/actions.hpp b/src/game/map_entities/actions.hpp index e69de29..968c60f 100644 --- a/src/game/map_entities/actions.hpp +++ b/src/game/map_entities/actions.hpp @@ -0,0 +1 @@ +// include all actions from folder \ No newline at end of file diff --git a/src/game/map_entities/cell.cpp b/src/game/map_entities/cell.cpp index e69de29..6ebb532 100644 --- a/src/game/map_entities/cell.cpp +++ b/src/game/map_entities/cell.cpp @@ -0,0 +1 @@ +#include "cell.hpp" \ No newline at end of file diff --git a/src/game/map_entities/cell.hpp b/src/game/map_entities/cell.hpp index e69de29..f647303 100644 --- a/src/game/map_entities/cell.hpp +++ b/src/game/map_entities/cell.hpp @@ -0,0 +1,24 @@ +#pragma ONCE + +namespace map { + enum CellType { // needed to choose final types + ctNone, + ctUnit, + ctWeapon, + ctForest, + ctMoutain + }; + + enum CellPlayer { + cpNone, + cpPlayer0, + cpPlayer1, + cpPlayer2, + cpPlayer3 + }; + + struct Cell { + CellType type; + // int ??speed??; // speed when move inside + }; +} \ No newline at end of file diff --git a/src/game/map_entities/unit_obj.cpp b/src/game/map_entities/unit_obj.cpp index e69de29..cc7f083 100644 --- a/src/game/map_entities/unit_obj.cpp +++ b/src/game/map_entities/unit_obj.cpp @@ -0,0 +1,5 @@ +#include "unit_obj.hpp" + +namespace map { + +} \ No newline at end of file diff --git a/src/game/map_entities/unit_obj.hpp b/src/game/map_entities/unit_obj.hpp index e69de29..2f29bfd 100644 --- a/src/game/map_entities/unit_obj.hpp +++ b/src/game/map_entities/unit_obj.hpp @@ -0,0 +1,29 @@ +#include +#include +#include "cell.hpp" +#include "../unit/unit.hpp" + +#pragma ONCE + +namespace map { + class UnitObj { + private: + Unit* unit; + std::pair pos; + std::pair size; + CellType cellType; + public: + UnitObj(Unit* unit) : unit(unit) { + + } + void updateValues() { + // from unit size, pos + } + void updatePosition() { + // from unit position + } + void updateAll() { + + } + }; +} \ No newline at end of file diff --git a/src/game/unit/module_builder.cpp b/src/game/unit/module_builder.cpp index e69de29..694a26c 100644 --- a/src/game/unit/module_builder.cpp +++ b/src/game/unit/module_builder.cpp @@ -0,0 +1,5 @@ +#include "module_builder.hpp" + +namespace unit { + +} \ No newline at end of file diff --git a/src/game/unit/module_builder.hpp b/src/game/unit/module_builder.hpp index e69de29..17d675f 100644 --- a/src/game/unit/module_builder.hpp +++ b/src/game/unit/module_builder.hpp @@ -0,0 +1,14 @@ +#include +#include "unit_module.hpp" + +#pragma ONCE + +namespace unit { + class ModuleBuilder { + private: + public: + ModuleBuilder(); + Module create(); + void config(const std::string& file); + }; +} \ No newline at end of file diff --git a/src/game/unit/modules.hpp b/src/game/unit/modules.hpp index e69de29..0aa3f7c 100644 --- a/src/game/unit/modules.hpp +++ b/src/game/unit/modules.hpp @@ -0,0 +1 @@ +// include all modules from folder \ No newline at end of file diff --git a/src/game/unit/unit.cpp b/src/game/unit/unit.cpp index e69de29..5420efd 100644 --- a/src/game/unit/unit.cpp +++ b/src/game/unit/unit.cpp @@ -0,0 +1,5 @@ +#include "unit.hpp" + +namespace unit { + +} \ No newline at end of file diff --git a/src/game/unit/unit.hpp b/src/game/unit/unit.hpp index e69de29..ab5d0fb 100644 --- a/src/game/unit/unit.hpp +++ b/src/game/unit/unit.hpp @@ -0,0 +1,15 @@ +#include +#include "unit_module.hpp" +#include "unit_memory_elem.hpp" + +#pragma ONCE + +namespace unit { + class Unit { + private: + std::vector modules; + std::vector memory; + public: + Unit(); + }; +} \ No newline at end of file diff --git a/src/game/unit/unit_memory.cpp b/src/game/unit/unit_memory.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/game/unit/unit_memory.hpp b/src/game/unit/unit_memory.hpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/game/unit/unit_memory_elem.hpp b/src/game/unit/unit_memory_elem.hpp new file mode 100644 index 0000000..20358c0 --- /dev/null +++ b/src/game/unit/unit_memory_elem.hpp @@ -0,0 +1,7 @@ +#pragma ONCE + +namespace unit { + struct MemoryElem { + int value = 0; + }; +} \ No newline at end of file diff --git a/src/game/unit/unit_module.cpp b/src/game/unit/unit_module.cpp index e69de29..9bc4e8d 100644 --- a/src/game/unit/unit_module.cpp +++ b/src/game/unit/unit_module.cpp @@ -0,0 +1,5 @@ +#include "unit_module.hpp" + +namespace unit { + +} \ No newline at end of file diff --git a/src/game/unit/unit_module.hpp b/src/game/unit/unit_module.hpp index e69de29..c954205 100644 --- a/src/game/unit/unit_module.hpp +++ b/src/game/unit/unit_module.hpp @@ -0,0 +1,17 @@ +// #include "unit.hpp" // ?? + +#pragma ONCE + +namespace unit { + class Module { + private: + public: + Module(); + /*virtual void connect(Unit* unit) { + + } + virtual void disconnect(Unit* unit) { + + }*/ + }; +} \ No newline at end of file diff --git a/src/out_api/draw.cpp b/src/out_api/draw.cpp index 6f0b354..78cb046 100644 --- a/src/out_api/draw.cpp +++ b/src/out_api/draw.cpp @@ -1,21 +1,8 @@ -#include "draw.hpp" #include -#include #include +#include "draw.hpp" namespace draw { - - enum Color { - black = 0, - red = 1, - green = 2, - yellow = 3, - blue = 4, - magneta = 5, - cyan = 6, - white = 7, - }; - void initColorPairs() { init_pair(ColorScheme::simple, COLOR_BLACK, COLOR_WHITE); init_pair(ColorScheme::active, COLOR_WHITE, COLOR_BLACK); @@ -25,24 +12,19 @@ namespace draw { init_pair(ColorScheme::player3, COLOR_BLACK, COLOR_YELLOW); init_pair(ColorScheme::neutral, COLOR_WHITE, COLOR_GREEN); init_pair(ColorScheme::enviroment, COLOR_BLACK, COLOR_WHITE); + init_pair(ColorScheme::damaged, COLOR_RED, COLOR_WHITE); } void begin() { - initscr(); - noecho(); - curs_set(false); start_color(); initColorPairs(); } void step() { refresh(); - usleep(STEP_DELAY_USEC); } - void end() { - endwin(); - } + void end() {} void clearAll() { clear(); diff --git a/src/out_api/draw.hpp b/src/out_api/draw.hpp index 29d98f0..ce91f49 100644 --- a/src/out_api/draw.hpp +++ b/src/out_api/draw.hpp @@ -1,5 +1,6 @@ #include -#include + +#pragma ONCE namespace draw { @@ -11,6 +12,7 @@ namespace draw { player2, player3, neutral, + damaged, enviroment }; @@ -23,8 +25,6 @@ namespace draw { unit = '#' }; - const uint32_t STEP_DELAY_USEC = 30000; - void begin(); void step(); diff --git a/src/out_api/init.cpp b/src/out_api/init.cpp new file mode 100644 index 0000000..e9ffb6c --- /dev/null +++ b/src/out_api/init.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include "init.hpp" +#include "draw.hpp" +#include "input.hpp" + +namespace init { + void begin() { + initscr(); + noecho(); + curs_set(false); + draw::begin(); + input::begin(); + } + + void step() { + draw::step(); + usleep(STEP_DELAY_USEC); + } + + void end() { + draw::end(); + input::end(); + endwin(); + } +} \ No newline at end of file diff --git a/src/out_api/init.hpp b/src/out_api/init.hpp new file mode 100644 index 0000000..7bcb502 --- /dev/null +++ b/src/out_api/init.hpp @@ -0,0 +1,14 @@ +#include + +#pragma ONCE + +namespace init { + + const uint32_t STEP_DELAY_USEC = 30000; + + void begin(); + + void step(); + + void end(); +} \ No newline at end of file diff --git a/src/out_api/input.cpp b/src/out_api/input.cpp index e69de29..2ddf7cf 100644 --- a/src/out_api/input.cpp +++ b/src/out_api/input.cpp @@ -0,0 +1,17 @@ +#include +#include +#include "input.hpp" + +namespace input { + void begin() { + + } + + void step() { + + } + + void end() { + + } +} \ No newline at end of file diff --git a/src/out_api/input.hpp b/src/out_api/input.hpp index e69de29..039becd 100644 --- a/src/out_api/input.hpp +++ b/src/out_api/input.hpp @@ -0,0 +1,12 @@ +#include + +#pragma ONCE + +namespace input { + + void begin(); + + void step(); + + void end(); +} \ No newline at end of file