Code: Show/Hide if(map[getLinear(x, y)] == vieNoTile) //from the MapTileFormat enum defined in map.h |
Code: Show/Hide x x x
x S x x x x |
Code: Show/Hide const int mapSize = 1024;
const int clearTiles[] = { 0 /* blank */, 170 /* flag */, 171 /* safe zone */, 172 /* soccer goal */, 173, 174, 175 /* fly over */, 176, 177, 178, 179, 180, 181, 182, 183, 184 /* fly under opaque */, 185, 186, 187, 188, 189, 190 /* fly under transparent */ }; int xTile, yTile; for(bool foundGoodTile = false; !foundGoodTile;) { // pick a random tile not on the border xTile = 1 + rand() % (mapSize - 2); yTile = 1 + rand() % (mapSize - 2); // check if there's any walls near it for (int dy = -1; dy <= 1; ++dy) for (int dx = -1; dx <= 1; ++dx) { int curXTile = xTile + dx; int curYTile = yTile + dy; int curIndex = curXTile + mapSize * curYTile; bool isClear = false; foundGoodTile = true; // this spot is good unless we prove otherwise for (unsigned int c = 0; c < sizeof(clearTiles) / sizeof(clearTiles[0]); ++c) { if (clearTiles[c] == map[curIndex]) { isClear = true; break; } } if (!isClear) // this spot is no good, jump out of both for loops and try a new spot { foundGoodTile = false; goto end_checking_walls; } } end_checking_walls: ; } sendPrivate(p, "*warpto " + (String)xTile + " " + (String)yTile); |
The Cubbies wrote: |
I just realized that I needed to #include "..\map.cpp" |