mirror of
https://github.com/ProgramSnail/rts_game_backend.git
synced 2025-12-07 18:28:43 +00:00
some additional functions
This commit is contained in:
parent
8553878b4a
commit
5173f4f2a9
23 changed files with 214 additions and 24 deletions
|
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace map {
|
||||||
|
class Action {
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
void update();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
// include all actions from folder
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
#include "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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "unit_obj.hpp"
|
||||||
|
|
||||||
|
namespace map {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include <utility>
|
||||||
|
#include <cstdint>
|
||||||
|
#include "cell.hpp"
|
||||||
|
#include "../unit/unit.hpp"
|
||||||
|
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace map {
|
||||||
|
class UnitObj {
|
||||||
|
private:
|
||||||
|
Unit* unit;
|
||||||
|
std::pair<int32_t, int32_t> pos;
|
||||||
|
std::pair<int32_t, int32_t> size;
|
||||||
|
CellType cellType;
|
||||||
|
public:
|
||||||
|
UnitObj(Unit* unit) : unit(unit) {
|
||||||
|
|
||||||
|
}
|
||||||
|
void updateValues() {
|
||||||
|
// from unit size, pos
|
||||||
|
}
|
||||||
|
void updatePosition() {
|
||||||
|
// from unit position
|
||||||
|
}
|
||||||
|
void updateAll() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "module_builder.hpp"
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <string>
|
||||||
|
#include "unit_module.hpp"
|
||||||
|
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
class ModuleBuilder {
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
ModuleBuilder();
|
||||||
|
Module create();
|
||||||
|
void config(const std::string& file);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
// include all modules from folder
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "unit.hpp"
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include <vector>
|
||||||
|
#include "unit_module.hpp"
|
||||||
|
#include "unit_memory_elem.hpp"
|
||||||
|
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
class Unit {
|
||||||
|
private:
|
||||||
|
std::vector<Module> modules;
|
||||||
|
std::vector<MemoryElem> memory;
|
||||||
|
public:
|
||||||
|
Unit();
|
||||||
|
};
|
||||||
|
}
|
||||||
7
src/game/unit/unit_memory_elem.hpp
Normal file
7
src/game/unit/unit_memory_elem.hpp
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
struct MemoryElem {
|
||||||
|
int value = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "unit_module.hpp"
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,21 +1,8 @@
|
||||||
#include "draw.hpp"
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <unistd.h>
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
#include "draw.hpp"
|
||||||
|
|
||||||
namespace draw {
|
namespace draw {
|
||||||
|
|
||||||
enum Color {
|
|
||||||
black = 0,
|
|
||||||
red = 1,
|
|
||||||
green = 2,
|
|
||||||
yellow = 3,
|
|
||||||
blue = 4,
|
|
||||||
magneta = 5,
|
|
||||||
cyan = 6,
|
|
||||||
white = 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
void initColorPairs() {
|
void initColorPairs() {
|
||||||
init_pair(ColorScheme::simple, COLOR_BLACK, COLOR_WHITE);
|
init_pair(ColorScheme::simple, COLOR_BLACK, COLOR_WHITE);
|
||||||
init_pair(ColorScheme::active, COLOR_WHITE, COLOR_BLACK);
|
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::player3, COLOR_BLACK, COLOR_YELLOW);
|
||||||
init_pair(ColorScheme::neutral, COLOR_WHITE, COLOR_GREEN);
|
init_pair(ColorScheme::neutral, COLOR_WHITE, COLOR_GREEN);
|
||||||
init_pair(ColorScheme::enviroment, COLOR_BLACK, COLOR_WHITE);
|
init_pair(ColorScheme::enviroment, COLOR_BLACK, COLOR_WHITE);
|
||||||
|
init_pair(ColorScheme::damaged, COLOR_RED, COLOR_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin() {
|
void begin() {
|
||||||
initscr();
|
|
||||||
noecho();
|
|
||||||
curs_set(false);
|
|
||||||
start_color();
|
start_color();
|
||||||
initColorPairs();
|
initColorPairs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void step() {
|
void step() {
|
||||||
refresh();
|
refresh();
|
||||||
usleep(STEP_DELAY_USEC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void end() {
|
void end() {}
|
||||||
endwin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearAll() {
|
void clearAll() {
|
||||||
clear();
|
clear();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <curses.h>
|
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
namespace draw {
|
namespace draw {
|
||||||
|
|
||||||
|
|
@ -11,6 +12,7 @@ namespace draw {
|
||||||
player2,
|
player2,
|
||||||
player3,
|
player3,
|
||||||
neutral,
|
neutral,
|
||||||
|
damaged,
|
||||||
enviroment
|
enviroment
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -23,8 +25,6 @@ namespace draw {
|
||||||
unit = '#'
|
unit = '#'
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint32_t STEP_DELAY_USEC = 30000;
|
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
|
|
||||||
void step();
|
void step();
|
||||||
|
|
|
||||||
27
src/out_api/init.cpp
Normal file
27
src/out_api/init.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <curses.h>
|
||||||
|
#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();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/out_api/init.hpp
Normal file
14
src/out_api/init.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace init {
|
||||||
|
|
||||||
|
const uint32_t STEP_DELAY_USEC = 30000;
|
||||||
|
|
||||||
|
void begin();
|
||||||
|
|
||||||
|
void step();
|
||||||
|
|
||||||
|
void end();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <curses.h>
|
||||||
|
#include "input.hpp"
|
||||||
|
|
||||||
|
namespace input {
|
||||||
|
void begin() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void step() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void end() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#pragma ONCE
|
||||||
|
|
||||||
|
namespace input {
|
||||||
|
|
||||||
|
void begin();
|
||||||
|
|
||||||
|
void step();
|
||||||
|
|
||||||
|
void end();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue