-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6182d76
commit b9f1cad
Showing
5 changed files
with
121 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @file board.h | ||
* | ||
* LocalGen Module: GameEngine | ||
* | ||
* Map Boards | ||
* | ||
* Container of maps. | ||
*/ | ||
|
||
#include <cassert> | ||
#include <vector> | ||
|
||
#include "coord.h" | ||
|
||
#include "player.h" | ||
#include "tile.h" | ||
|
||
/// Game map board. Zoomable. | ||
class Board { | ||
private: | ||
pos_t row, col; | ||
std::vector<std::vector<Tile>> tiles; | ||
public: | ||
Board() : | ||
row(0), col(0) {} | ||
Board(pos_t _row, pos_t _col) : | ||
row(_row), col(_col) { | ||
// board index starts at 1. | ||
// give 1 space at borders for safety and convenience issues. | ||
tiles.resize(row + 2, std::vector<Tile>(col + 2)); | ||
} | ||
Tile getTile(pos_t x, pos_t y, Player* pplayer) { | ||
// test tile existance | ||
assert(x >= 1 && x <= row && y >= 1 && y <= col); | ||
// todo)) | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file player.h | ||
* | ||
* LocalGen Module: GameEngine | ||
* | ||
* Players | ||
* | ||
* Players are basic participants of games. | ||
*/ | ||
|
||
#ifndef LGEN_MODULE_GE_PLAYER | ||
#define LGEN_MODULE_GE_PLAYER 1 | ||
|
||
#include <string> | ||
|
||
/// Base struct for players. | ||
class Player { | ||
private: | ||
std::string name; | ||
public: | ||
}; // todo)) | ||
|
||
#endif // LGEN_MODULE_GE_PLAYER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @file tile.h | ||
* | ||
* LocalGen Module: GameEngine | ||
* | ||
* Tiles | ||
* | ||
* Tiles are basic elements of map boards. | ||
*/ | ||
|
||
#ifndef LGEN_MODULE_GE_TILE | ||
#define LGEN_MODULE_GE_TILE 1 | ||
|
||
#include <cstdint> | ||
|
||
#include "player.h" | ||
|
||
using army_t = int64_t; | ||
|
||
/// Tile types. | ||
/// Defined as enum for they're all constants. | ||
enum tile_type_e { | ||
/// Normal tile types. | ||
TILE_SPAWN = 0, | ||
TILE_BLANK = 1, | ||
TILE_MOUNTAIN = 2, | ||
TILE_CITY = 3, | ||
TILE_SWAMP = 4, | ||
TILE_DESERT = 5, | ||
TILE_LOOKOUT = 6, | ||
TILE_OBSERVATORY = 7, | ||
|
||
/// Mountains, cities, lookouts, observatories will appear as 'obstacles' if not visible. | ||
/// Give it a specific type number. It may appear as tile type return values. | ||
TILE_OBSTACLE = -1, | ||
}; | ||
|
||
// Some tiles have some properties. Some tiles have aliases. Make them macros. | ||
#define TILE_GENERAL TILE_SPAWN | ||
#define TILE_PLAIN TILE_BLANK | ||
#define TILE_NEUTRAL TILE_BLANK | ||
|
||
/// Information of a single tile. | ||
struct Tile { | ||
Player* occupier; | ||
tile_type_e type; | ||
army_t army; | ||
// Light is a tile attribute, not a tile type. | ||
bool light; | ||
}; | ||
|
||
#endif // LGEN_MODULE_GE_TILE |