mirror of
https://github.com/ProgramSnail/rts_game_backend.git
synced 2026-01-10 13:37:17 +00:00
develop classes
This commit is contained in:
parent
9be0f50790
commit
580ef8ac3c
15 changed files with 62 additions and 22 deletions
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <vector>
|
||||||
|
#include "map_entities/cell.hpp"
|
||||||
|
#include "map_entities/action.hpp"
|
||||||
|
#include "map_entities/unit_obj.hpp"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace map {
|
||||||
|
class GameMap {
|
||||||
|
private:
|
||||||
|
std::vector<std::vector<Cell> > cells;
|
||||||
|
std::vector<Action*> actions;
|
||||||
|
std::vector<UnitObj> units;
|
||||||
|
public:
|
||||||
|
GameMap() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace map {
|
namespace map {
|
||||||
class Action {
|
class Action {
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
// include all actions from folder
|
// include all actions from folder
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace map {
|
namespace map {
|
||||||
enum CellType { // needed to choose final types
|
enum CellType { // needed to choose final types
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,20 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "cell.hpp"
|
#include "cell.hpp"
|
||||||
#include "../unit/unit.hpp"
|
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace map {
|
namespace map {
|
||||||
class UnitObj {
|
class UnitObj { // may be useless
|
||||||
private:
|
private:
|
||||||
Unit* unit;
|
using Coord = std::pair<int32_t, int32_t>;
|
||||||
std::pair<int32_t, int32_t> pos;
|
Coord pos;
|
||||||
std::pair<int32_t, int32_t> size;
|
Coord size;
|
||||||
CellType cellType;
|
CellType cellType;
|
||||||
public:
|
public:
|
||||||
UnitObj(Unit* unit) : unit(unit) {
|
UnitObj(const Coord& pos, const Coord& size, const CellType& cellType) :
|
||||||
|
pos(pos), size(size), cellType(cellType) {
|
||||||
|
|
||||||
}
|
|
||||||
void updateValues() {
|
|
||||||
// from unit size, pos
|
|
||||||
}
|
|
||||||
void updatePosition() {
|
|
||||||
// from unit position
|
|
||||||
}
|
}
|
||||||
void updateAll() {
|
void updateAll() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "unit_module.hpp"
|
#include "unit_module.hpp"
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace unit {
|
namespace unit {
|
||||||
class ModuleBuilder {
|
class ModuleBuilder {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
ModuleBuilder();
|
ModuleBuilder();
|
||||||
|
|
||||||
Module create();
|
Module create();
|
||||||
|
|
||||||
void config(const std::string& file);
|
void config(const std::string& file);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
// include all modules from folder
|
// include all modules from folder
|
||||||
|
|
@ -1,15 +1,19 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "../game_map.hpp"
|
||||||
#include "unit_module.hpp"
|
#include "unit_module.hpp"
|
||||||
#include "unit_memory_elem.hpp"
|
#include "unit_memory_elem.hpp"
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace unit {
|
namespace unit {
|
||||||
class Unit {
|
class Unit {
|
||||||
private:
|
private:
|
||||||
std::vector<Module> modules;
|
std::vector<Module> modules;
|
||||||
std::vector<MemoryElem> memory;
|
std::vector<MemoryElem> memory;
|
||||||
|
map::GameMap map;
|
||||||
public:
|
public:
|
||||||
Unit();
|
Unit();
|
||||||
|
|
||||||
|
void update();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
#include "unit_builder.hpp"
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include <string>
|
||||||
|
#include "unit.hpp"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace unit {
|
||||||
|
class UnitBuilder {
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
UnitBuilder();
|
||||||
|
|
||||||
|
Unit create();
|
||||||
|
|
||||||
|
void config(std::string& file);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace unit {
|
namespace unit {
|
||||||
struct MemoryElem {
|
struct MemoryElem {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// #include "unit.hpp" // ??
|
// #include "unit.hpp" // ??
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace unit {
|
namespace unit {
|
||||||
class Module {
|
class Module {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace draw {
|
namespace draw {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace init {
|
namespace init {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#pragma ONCE
|
#pragma once
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue