在过去的几天里,我一直在试图找出如何链接我一直在努力的CLI游戏项目的文件.项目有两半,即客户端和服务器代码.
客户需要我制作的两个库.第一个是通用游戏板.这在GameEngine.h和GameEngine.cpp之间分开.头文件看起来像这样
namespace gfdGaming {
// struct sqr_size {
// Index x;
// Index y;
// };
typedef struct { Index x, y; } sqr_size;
const sqr_size sPos = {1, 1};
sqr_size sqr(Index x, Index y);
sqr_size ePos;
class board
{
// Prototypes / declarations for the class
}
}
Run Code Online (Sandbox Code Playgroud)
CPP文件只是提供所有内容
#include "GameEngine.h"
type gfdGaming::board::functions
Run Code Online (Sandbox Code Playgroud)
客户端还将特定于游戏的代码(在本例中为TicTacToe)拆分为声明和定义(TTT.h,Client.cpp).TTT.h基本上是
#include "GameEngine.h"
#define TTTtar "localhost"
#define TTTport 2886
using namespace gfdGaming;
void* turnHandler(void*);
namespace nsTicTacToe
{
GFDCON gfd;
const char X = 'X';
const …Run Code Online (Sandbox Code Playgroud)