我认为我对宏的理解是错误的。我正在使用 curses 制作游戏,我想生成一张地图(现在统一挑选瓷砖,因为我无法让任何我发现工作的分布采样器)。
#include "Map.h"
/* Our ingame tiles */
#define WATER Tile(COLOR_BLUE,COLOR_CYAN,std::string(1, static_cast<char>(247)));
#define LAVA Tile(COLOR_YELLOW, COLOR_RED, std::string(1, static_cast<char>(247)));
#define ANIMAL Tile(COLOR_MAGENTA, COLOR_BLACK, std::string(1, static_cast<char>(224)));
#define PATH Tile(COLOR_WHITE, COLOR_WHITE, std::string(1, static_cast<char>(32)));
//static int pathPx = 5;
//static int lavaPx = 2;
//static int waterPx = 2;
//static int animalPx = 1;
std::vector<Tile> tiles = {PATH, LAVA, WATER, ANIMAL};
std::vector< std::vector<Tile> > map;
Map::Map(){
srand(time(NULL));
int y = rand() % 10 + 10;
int x = rand() % 10 + 10;
for (int j=0; j<y; j++){
std::vector<Tile> tileRowi;
for (int i=0; i<x; i++){
int n = rand()%4+1;
tileRowi.push_back(tiles[n]);
}
}
}
错误是:
First: c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/basic_string.h initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' [-fpermissive]
第二个:invalid conversion from 'char' to 'const char*' [-fpermissive]
第一个说我的一个文件的第 485 行......但没有第 485 行。第二个在:
std::vector<Tile> tiles = {PATH, LAVA, WATER, ANIMAL};
编辑 -
这是我的瓷砖课程:
#include "Tile.h"
int backgroundColor;
int foregroundColor;
std::string rep;
Tile::Tile(int fc, int bc, std::string r){
backgroundColor = bc;
foregroundColor = fc;
rep = r;
}
编辑 2--工作区图片