本文整理汇总了C++中MapPoint::GetNeighborPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ MapPoint::GetNeighborPosition方法的具体用法?C++ MapPoint::GetNeighborPosition怎么用?C++ MapPoint::GetNeighborPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapPoint
的用法示例。
在下文中一共展示了MapPoint::GetNeighborPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindContinentNeighbors
void World::FindContinentNeighbors()
{
sint16 center_cont;
MapPoint center;
MapPoint test_cont;
bool is_land = false;
AllocateNeighborMem();
for(center.x=0; center.x<m_size.x; center.x++) {
for(center.y=0; center.y<m_size.y; center.y++) {
GetContinent(center, center_cont, is_land);
Assert(0 <= center_cont);
if (center_cont < 0) continue;
if(center.GetNeighborPosition(NORTHWEST, test_cont))
FindAContinentNeighbor(center_cont, test_cont, is_land);
if(center.GetNeighborPosition(WEST, test_cont))
FindAContinentNeighbor(center_cont, test_cont, is_land);
if(center.GetNeighborPosition(SOUTHWEST, test_cont))
FindAContinentNeighbor(center_cont, test_cont, is_land);
if(center.GetNeighborPosition(SOUTH, test_cont))
FindAContinentNeighbor(center_cont, test_cont, is_land);
}
}
}
示例2: GrowLand
void World::GrowLand(MapPoint const & start)
{
MapPointNode * search_list = NULL;
AddToLandSearch(search_list, start);
MapPoint test_pos;
MapPoint center;
MapPointNode * finished_list = NULL;
#ifdef _DEBUG
sint32 finite_loop = 0;
#endif
while (NextPoint(search_list, finished_list, center))
{
Assert(++finite_loop < 100000);
if(center.GetNeighborPosition(NORTH, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(NORTHEAST, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(NORTHWEST, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(EAST, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(WEST, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(SOUTH, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(SOUTHEAST, test_pos))
AddToLandSearch(search_list, test_pos);
if(center.GetNeighborPosition(SOUTHWEST, test_pos))
AddToLandSearch(search_list, test_pos);
}
#ifdef _DEBUG
finite_loop=0;
#endif
while (finished_list)
{
Assert(++finite_loop < 100000);
MapPointNode * ptr = finished_list;
finished_list = finished_list->next;
GetCell(ptr->pos)->SetContinent(m_land_continent_max);
delete ptr;
}
m_land_continent_max++;
Assert(LAND_CONTINENT_START < m_land_continent_max);
}
示例3: ui_HandleKeypress
//.........这里部分代码省略.........
InfoWindow::SelectWonderTab();
InfoWindow::Open();
}
break;
case KEY_FUNCTION_RANK:
if(!g_modalWindow) {
InfoWindow::SelectRankingTab();
InfoWindow::Open();
}
break;
case KEY_FUNCTION_RESTART:
//Added by Martin Gühmann to disable also the restart key in network
//games, hot seat games and email games.
if(!g_modalWindow
&& !g_theProfileDB->IsScenario()
&& !g_isScenario
&& !g_network.IsActive()
&& !g_turn->IsHotSeat()
&& !g_turn->IsEmail()
) {
optionwarningscreen_displayMyWindow(OWS_RESTART) ;
}
break;
case KEY_FUNCTION_NEW_GAME:
if(!g_modalWindow) {
optionwarningscreen_displayMyWindow(OWS_QUITTOSHELL);
}
break;
case KEY_FUNCTION_SOUND_OPTIONS:
if(!g_modalWindow) {
soundscreen_displayMyWindow();
}
break;
// MUSIC added by ahenobarb
case KEY_FUNCTION_MUSIC_OPTIONS:
if(!g_modalWindow) {
musicscreen_displayMyWindow();
}
break;
case KEY_FUNCTION_GRAPHICS_OPTIONS:
if(!g_modalWindow) {
graphicsscreen_displayMyWindow();
}
break;
case KEY_FUNCTION_GAMEPLAY_OPTIONS:
if(!g_modalWindow) {
gameplayoptions_displayMyWindow();
}
break;
case KEY_FUNCTION_ADVANCED_OPTIONS:
if(!g_modalWindow) {
ProfileEdit::Display();
}
break;
default :
Assert(FALSE);
}
if (move && isMyTurn) {
PLAYER_INDEX s_player;
ID s_item;
SELECT_TYPE s_state;
g_selected_item->GetTopCurItem(s_player, s_item, s_state);
switch(s_state) {
case SELECT_TYPE_LOCAL_ARMY:
{
Army army(s_item);
MapPoint pos;
army.GetPos(pos);
MapPoint newpos;
if(pos.GetNeighborPosition(d, newpos)) {
g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_MoveToOrder,
GEA_Army, army.m_id,
GEA_Direction, d,
GEA_End);
g_selected_item->DidKeyboardMove();
}
break;
}
default:
break;
}
}
return TRUE;
}
示例4: if
void TiledMap::DrawRoads
(
aui_Surface *surface,
const MapPoint &pos,
sint32 x,
sint32 y,
uint16 roadOffset,
bool fog,
sint32 flags
)
{
MapPoint newPos;
sint32 isConnectStraight = 0;
sint32 isConnectDiagonal = 0;
sint32 neighborFlag = 0;
Pixel16 *data;
for(WORLD_DIRECTION d = NORTH; d < NOWHERE; d = (WORLD_DIRECTION)((sint32)d + 1))
{
if(pos.GetNeighborPosition(d, newPos))
{
if(g_theWorld->IsAnyRoad(newPos)
|| g_theWorld->IsTunnel(newPos)
|| g_theWorld->IsCity(newPos)
){
neighborFlag |= (1 << d);
if(d == NORTH
|| d == EAST
|| d == WEST
|| d == SOUTH
){
isConnectStraight++;
}
else
{
isConnectDiagonal++;
}
}
}
}
data = m_tileSet->GetRoadData(ROAD_MAGLEVPOST+roadOffset);
if(data)
{
DrawARoadPiece(surface, data, x, y, fog);
}
if (!isConnectStraight && !isConnectDiagonal)
{
data = m_tileSet->GetRoadData(ROAD_NORTH+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
return;
}
if (isConnectStraight == k_X_INTERSECT)
{
data = m_tileSet->GetRoadData(ROAD_X_STRAIGHT+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
else if (isConnectStraight == k_T_INTERSECT)
{
if ((neighborFlag & k_T_SOUTH) == k_T_SOUTH)
{
data = m_tileSet->GetRoadData(ROAD_T_SOUTH+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
else if ((neighborFlag & k_T_WEST) == k_T_WEST)
{
data = m_tileSet->GetRoadData(ROAD_T_WEST+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
else if ((neighborFlag & k_T_NORTH) == k_T_NORTH)
{
data = m_tileSet->GetRoadData(ROAD_T_NORTH+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
else /*if((neighborFlag & k_T_EAST) == k_T_EAST) */
{
data = m_tileSet->GetRoadData(ROAD_T_EAST+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
}
else if (isConnectStraight)
{
if (neighborFlag & k_BIT_SOUTH)
{
data = m_tileSet->GetRoadData(ROAD_SOUTH+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
if (neighborFlag & k_BIT_WEST)
{
data = m_tileSet->GetRoadData(ROAD_WEST+roadOffset);
DrawARoadPiece(surface, data, x, y, fog);
}
if (neighborFlag & k_BIT_NORTH)
{
//.........这里部分代码省略.........
示例5: ClipGF
void World::ClipGF(sint16 **tmp_map)
{
MapPoint pos;
MapPoint w;
sint16 v;
sint16 threshold_min = 1;
sint16 threshold_max = 1;
sint32 count = 0;
for (pos.x=0; pos.x<m_size.x; pos.x++) {
for (pos.y=0; pos.y<m_size.y; pos.y++) {
sint16 curr = tmp_map[pos.x][pos.y];
if ((1 == curr)) {
count=0;
if(pos.GetNeighborPosition(NORTHEAST, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (0 == v) count++;
}
if(pos.GetNeighborPosition(NORTHWEST, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (0 == v) count++;
}
if(pos.GetNeighborPosition(SOUTHWEST, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (0 == v) count++;
}
if(pos.GetNeighborPosition(SOUTHEAST, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (0 == v) count++;
}
if (3 == count) {
curr = -curr;
tmp_map[pos.x][pos.y] = curr;
}
}
}
}
for (pos.x=0; pos.x<m_size.x; pos.x++) {
for (pos.y=0; pos.y<m_size.y; pos.y++) {
if (tmp_map[pos.x][pos.y] < 0) {
tmp_map[pos.x][pos.y] = 0;
}
}
}
bool going_up = false;
for (pos.x=0; pos.x<m_size.x; pos.x++) {
for (pos.y=0; pos.y<m_size.y; pos.y++) {
sint16 curr = tmp_map[pos.x][pos.y];
if ((threshold_min <= curr) && (curr <= threshold_max)) {
if(pos.GetNeighborPosition(SOUTHEAST, w)) {
count = 0;
v = tmp_map[w.x][w.y];
going_up = v < threshold_min;
}
if(pos.GetNeighborPosition(EAST, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (going_up) {
if (threshold_max <= v) {
going_up = false;
count++;
}
} else {
if (v < threshold_min) {
going_up = true;
count++;
}
}
}
if(pos.GetNeighborPosition(NORTHEAST, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (going_up) {
if (threshold_max <= v) {
going_up = false;
count++;
}
} else {
if (v < threshold_min) {
going_up = true;
count++;
}
}
}
if(pos.GetNeighborPosition(NORTH, w)) {
v = sint16(abs(tmp_map[w.x][w.y]));
if (going_up) {
//.........这里部分代码省略.........
示例6:
void World::Grassfire8(bool is_choke_land, sint16 **tmp_map)
{
MapPoint pos;
for (pos.x=0; pos.x < m_size.x; pos.x++) {
for (pos.y=0; pos.y < m_size.y; pos.y++) {
if (IsGFComputed(is_choke_land, pos)) {
tmp_map[pos.x][pos.y] = 9999;
} else {
tmp_map[pos.x][pos.y] =0;
}
}
}
sint16 v, mv = 0; // Reconsider!
MapPoint w;
for (pos.x=0; pos.x < m_size.x; pos.x++) {
for (pos.y=0; pos.y < m_size.y; pos.y++) {
if (IsGFComputed(is_choke_land, pos)) {
if(pos.GetNeighborPosition(NORTHWEST, w)) {
v = tmp_map[w.x][w.y];
if (v < mv) mv = v;
}
if(pos.GetNeighborPosition(WEST, w)) {
v = tmp_map[w.x][w.y];
mv = v;
}
if(pos.GetNeighborPosition(SOUTHWEST, w)) {
v = tmp_map[w.x][w.y];
if (v < mv) mv = v;
}
if(pos.GetNeighborPosition(SOUTH, w)) {
v = tmp_map[w.x][w.y];
if (v < mv) mv = v;
}
mv++;
tmp_map[pos.x][pos.y] = mv;
} else {
tmp_map[pos.x][pos.y] = 0;
}
}
}
for (pos.x=(m_size.x-1); 0<=pos.x; pos.x--) {
for (pos.y=(m_size.y-1); 0<=pos.y; pos.y--) {
if (IsGFComputed(is_choke_land, pos)) {
if(pos.GetNeighborPosition(SOUTHEAST, w)) {
v = tmp_map[w.x][w.y];
mv = v;
}
if(pos.GetNeighborPosition(EAST, w)) {
v = tmp_map[w.x][w.y];
if (v < mv) mv = v;
}
if(pos.GetNeighborPosition(NORTHEAST, w)) {
v = tmp_map[w.x][w.y];
if (v < mv) mv = v;
}
if(pos.GetNeighborPosition(NORTH, w)) {
v = tmp_map[w.x][w.y];
if (v < mv) mv = v;
}
v = tmp_map[pos.x][pos.y];
if (mv < v) {
mv++;
tmp_map[pos.x][pos.y] = mv;
}
} else {
tmp_map[pos.x][pos.y] = 0;
}
}
}
}