当前位置: 首页>>代码示例>>C++>>正文


C++ WorldMap类代码示例

本文整理汇总了C++中WorldMap的典型用法代码示例。如果您正苦于以下问题:C++ WorldMap类的具体用法?C++ WorldMap怎么用?C++ WorldMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WorldMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AdjustScrolling

/** Mouse Over Event */
void WorldMapControl::OnMouseOver(unsigned short x, unsigned short y)
{
	WorldMap* worldmap = core->GetWorldMap();
	lastCursor = IE_CURSOR_GRAB;

	if (MouseIsDown) {
		AdjustScrolling(lastMouseX-x, lastMouseY-y);
	}

	lastMouseX = x;
	lastMouseY = y;

	if (Value!=(ieDword) -1) {
		x =(ieWord) (x + ScrollX);
		y =(ieWord) (y + ScrollY);

		WMPAreaEntry *oldArea = Area;
		Area = NULL;

		unsigned int i;
		unsigned int ec = worldmap->GetEntryCount();
		for (i=0;i<ec;i++) {
			WMPAreaEntry *ae = worldmap->GetEntry(i);

			if ( (ae->GetAreaStatus() & WMP_ENTRY_WALKABLE)!=WMP_ENTRY_WALKABLE) {
				continue; //invisible or inaccessible
			}

			Sprite2D *icon=ae->GetMapIcon(worldmap->bam);
			int h=0, w=0, iconx=0, icony=0;
			if (icon) {
				h=icon->Height;
				w=icon->Width;
				iconx = icon->XPos;
				icony = icon->YPos;
				core->GetVideoDriver()->FreeSprite( icon );
			}
			if (ftext && ae->GetCaption()) {
				int tw = ftext->CalcStringWidth( (unsigned char*)ae->GetCaption() ) + 5;
				int th = ftext->maxHeight;
				if(h<th)
					h=th;
				if(w<tw)
					w=tw;
			}
			if (ae->X - iconx > x) continue;
			if (ae->X - iconx + w < x) continue;
			if (ae->Y - icony > y) continue;
			if (ae->Y - icony + h < y) continue;
			lastCursor = IE_CURSOR_NORMAL;
			Area=ae;
			if(oldArea!=ae) {
				RunEventHandler(WorldMapControlOnEnter);
			}
			break;
		}
	}

	Owner->Cursor = lastCursor;
}
开发者ID:jadeatucker,项目名称:gemrb,代码行数:61,代码来源:WorldMapControl.cpp

示例2: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    WorldMap worldmap;
    for(int i = 0; i < DIMENSION; ++i)
    {
        WorldRow row;
        for(int j = 0; j < DIMENSION; ++j)
            row.append(WHITE);
        worldmap.append(row);
    }

    qDebug() << "antling worker";


    Ant antling(EAST, QPoint(DIMENSION/2, DIMENSION/2), worldmap);


    //viewWorldmap(antling.worldMap());
    for(int i = 0; i < 25000; ++i)
    {
        antling.move();
    }
qDebug() << "====================================";
   // viewWorldmap(antling.worldMap());

    ImageGenerator gen(antling.worldMap(), DIMENSION);

    gen.renderImageAndSave("/home/ipek/Downloads/");

    return 0;
}
开发者ID:redukt0r,项目名称:antling,代码行数:33,代码来源:main.cpp

示例3: CopyResRef

WorldMapControl::WorldMapControl(const char *font, int direction)
{
	ScrollX = 0;
	ScrollY = 0;
	MouseIsDown = false;
	Changed = true;
	Area = NULL;
	Value = direction;
	Game* game = core->GetGame();
	WorldMap* worldmap = core->GetWorldMap();
	CopyResRef(currentArea, game->CurrentArea);
	int entry = core->GetAreaAlias(currentArea);
	if (entry >= 0) {
		WMPAreaEntry *m = worldmap->GetEntry(entry);
		CopyResRef(currentArea, m->AreaResRef);
	}

	//if there is no trivial area, look harder
	if (!worldmap->GetArea(currentArea, (unsigned int &) entry) && 
		core->HasFeature(GF_FLEXIBLE_WMAP) ) {
		WMPAreaEntry *m = worldmap->FindNearestEntry(currentArea, (unsigned int &) entry);
		if (m) {
			CopyResRef(currentArea, m->AreaResRef);
		}
	}

	//this also updates visible locations
	worldmap->CalculateDistances(currentArea, Value);
	
	// alpha bit is unfortunately ignored
	if (font[0]) {
		ftext = core->GetFont(font);
	} else {
		ftext = NULL;
	}

	// initialize label colors
	// NOTE: it would be better to initialize these colors from
	//   some 2da file
	Color normal = { 0xf0, 0xf0, 0xf0, 0xff };
	Color selected = { 0xf0, 0x80, 0x80, 0xff };
	Color notvisited = { 0x80, 0x80, 0xf0, 0xff };
	Color black = { 0x00, 0x00, 0x00, 0x00 };

	pal_normal = core->CreatePalette ( normal, black );
	pal_selected = core->CreatePalette ( selected, black );
	pal_notvisited = core->CreatePalette ( notvisited, black );


	ResetEventHandler( WorldMapControlOnPress );
	ResetEventHandler( WorldMapControlOnEnter );
}
开发者ID:jadeatucker,项目名称:gemrb,代码行数:52,代码来源:WorldMapControl.cpp

示例4: assert

int WMPImporter::GetStoredFileSize(WorldMapArray *wmap, unsigned int index)
{
	assert(!index || !wmap->IsSingle());

	int headersize = 16;
	int WorldMapsOffset;

	WorldMapsCount = wmap->GetMapCount();
	if (index>WorldMapsCount || index>1) return 0;

	WorldMapsOffset = headersize;
	if (index) {
		WorldMapsCount2 = 0;
	} else {
		WorldMapsCount1 = 0;
	}

	for (unsigned int i=index;i<WorldMapsCount; i++) {
		if (index) {
			WorldMapsCount2++;
		} else {
			WorldMapsCount1++;
		}

		headersize += 184;
		WorldMap *map = wmap->GetWorldMap(i);

		//Update the links and entries counts now, in case the worldmap has changed
		map->AreaEntriesCount = map->GetEntryCount();
		headersize += map->AreaEntriesCount * 240;

		map->AreaLinksCount = map->GetLinkCount();
		headersize += map->AreaLinksCount * 216;

		//put the first array into the first map
		//the rest into the second map if not single
		if (!wmap->IsSingle() && !index) {
			break;
		}
	}

	if (index) {
		WorldMapsOffset2 = WorldMapsOffset;
	}
	else {
		WorldMapsOffset1 = WorldMapsOffset;
	}
	return headersize;
}
开发者ID:scriptedfate,项目名称:gemrb,代码行数:49,代码来源:WMPImporter.cpp

示例5: drillSpiral

void FeatureGenerator::drillSpiral(
  v3d_t top,
  double radius,
  double height,
  double totalRotation,
  int numSteps,
  WorldMap &worldMap)
{
  v3d_t pos;

  double bottom = top.y - height;
  double percent;
  double angle;

  for (int step = 0; step < numSteps; step++) {
    percent = static_cast<double> (step) / static_cast<double>(numSteps - 1);
    angle = percent * totalRotation;

    pos.x = top.x + radius * cos(angle);
    pos.y = lerp(bottom, top.y, percent);
    pos.z = top.z + radius * sin(angle);

    worldMap.clearSphere(pos, 3.0);
  }
}
开发者ID:jrbeck,项目名称:longshot,代码行数:25,代码来源:FeatureGenerator.cpp

示例6: Context

void MapSpatialComponent::OnRemove()
{
	Context()->chitBag->RemoveFromBuildingHash(this, bounds.min.x, bounds.min.y);
	
	WorldMap* worldMap = Context()->worldMap;
	LumosChitBag* chitBag = Context()->chitBag;

	super::OnRemove();

	// Since we are removed from the HashTable, this
	// won't be found by UpdateGridLayer()
	Rectangle2I b = bounds;
	b.Outset(1);
	worldMap->UpdateBlock(bounds);
	UpdateGridLayer(worldMap, chitBag, b);
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:16,代码来源:mapspatialcomponent.cpp

示例7: OnMouseWheelScroll

/** Mouse wheel scroll */
void WorldMapControl::OnMouseWheelScroll(short x, short y)
{
	ScrollX += x;
	ScrollY += y;
	
	WorldMap* worldmap = core->GetWorldMap();
	Sprite2D *MapMOS = worldmap->GetMapMOS();
	if (ScrollX > MapMOS->Width - Width)
		ScrollX = MapMOS->Width - Width;
	if (ScrollY > MapMOS->Height - Height)
		ScrollY = MapMOS->Height - Height;
	if (ScrollX < 0)
		ScrollX = 0;
	if (ScrollY < 0)
		ScrollY = 0;
}
开发者ID:jadeatucker,项目名称:gemrb,代码行数:17,代码来源:WorldMapControl.cpp

示例8: blitTile

void
GameView::drawMap(Surface &window)
{
    TileSet * ts = TileInterface::getTileSet();
    unsigned long world_x;
    unsigned long world_y;
    unsigned short map_x;
    unsigned short map_y;
    
    WorldViewInterface::getMainCamera()->getViewStart(window.getWidth(), window.getHeight(),
                              &world_x, &world_y);
    MapInterface::pointXYtoMapXY( world_x, world_y, &map_x, &map_y );
        
    unsigned short tile_size = ts->getTileXsize();
    
    long partial_y = world_y % tile_size;
    int y = 0;
    if ( partial_y )
    {
        y -= partial_y;
    }
    
    long partial_x = world_x % tile_size;
    int start_x = 0;
    if ( partial_x )
    {
        start_x -= partial_x;
    }
    
    unsigned int tile = 0;
    
    WorldMap * map = MapInterface::getMap();
    
    unsigned short tmx;
    
    for ( ; y < (int)window.getHeight(); y += tile_size )
    {
        tmx = map_x;
        for ( int x = start_x; x < (int)window.getWidth(); x += tile_size )
        {
            tile = map->getValue(tmx++, map_y);
            blitTile(window, tile, x, y);
        }
        map_y ++;
    }
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:46,代码来源:GameView.cpp

示例9: Init

void IMSystemManager::Init(const IMSysManagerParam& p_params)
{
    int worldWidth;
    int worldHeight;
    WorldMap *pMap = nullptr;
    int cellSize;

    if (m_initialized)
    {
        LogError("IMSystemManager already initialized, will do nothing ...");
        return;
    }

    m_params = p_params;

    pMap = g_Game->Map();
    worldWidth = pMap->Size().X;
    worldHeight = pMap->Size().Y;
    
    cellSize = p_params.BuildingDataIMCellSize;
    cellSize = min(cellSize, worldWidth);
    while (worldWidth % cellSize != 0)
        ++cellSize;

    OccupanceDataIM *pBuildingDataIM = new OccupanceDataIM(IM_BuildingData);
    assert(pBuildingDataIM);
    pBuildingDataIM->Init(cellSize, cellSize, worldWidth, worldHeight);
    RegisterIM(pBuildingDataIM, IM_BuildingData);

    cellSize = p_params.GroundControlIMCellSize;
    cellSize = min(cellSize, worldWidth);
    while (worldWidth % cellSize != 0)
        ++cellSize;

    GroundControlIM *pGroundControlIM = new GroundControlIM(IM_GroundControl);
    assert(pGroundControlIM);
    pGroundControlIM->Init(cellSize, cellSize, worldWidth, worldHeight);
    RegisterIM(pGroundControlIM, IM_GroundControl);

    m_initialized = true;
}
开发者ID:amrElroumy,项目名称:IStrategizer,代码行数:41,代码来源:IMSystemManager.cpp

示例10: infile

WorldMap* MapReader::readMap(std::string filename) {
	std::ifstream infile(filename.c_str());
	int cellWidth = 0;
	int cellHeight = 0;
	int nextTileVal = 0;
	std::stringstream lineStream;

	infile >> cellWidth >> cellHeight;
	WorldMap* map = new WorldMap(cellWidth, cellHeight, Terrain::getSize());

	std::cout << "Loading map [" << filename << "]   (" << cellWidth << ", " << cellHeight << ")" << std::endl;

	// Loop through each row of the map
	for (int height = 0; height < cellHeight; ++height) {
		// Loop through each column of the map
		for (int width = 0; width < cellWidth; ++width) {
			infile >> nextTileVal;

			// Special case -- victory condition
			if (nextTileVal == 2) {
				Manager::getInstance()->getTarget()->setLocation(width * Terrain::getSize(), height * Terrain::getSize());
			}
			// All other cases.
			else {
				Terrain * nextTileType = getTileType(nextTileVal);
				if (nextTileType != NULL) {
					map->setCell(width, height, nextTileType);
				}
			}
		}
		lineStream.str("");
	}

	/*
	for (int width = 0; width < cellWidth; ++width) {
		map->setCell(width, cellHeight - 1, getTileType(1));
	}
	*/

	return map;
}
开发者ID:asegars,项目名称:416-game,代码行数:41,代码来源:MapReader.cpp

示例11: WorldMap

WorldMap* WorldMap::createDefaultMap()
{
   WorldMap* m = new WorldMap(12l, 12);

   for(int x=0; x<12; x++)
   {   
      for(int y=0; y<12; y++)
      {
         if (x ==0 || y == 0 || x == 11 || y == 11)
            m->setElement(x, y, TERRAIN_OCEAN);
         else
            m->setElement(x, y, TERRAIN_GRASS);

         m->setStructure(x, y, STRUCTURE_NONE);
      }
   }

   m->setElement(5, 5, TERRAIN_ROCK);

   return m;
}
开发者ID:weretaco,项目名称:network-game,代码行数:21,代码来源:WorldMap.cpp

示例12: viewWorldmap

void viewWorldmap(WorldMap map)
{

    for(int i = 0; i < map.size(); ++ i)
    {
        QString row;
        for(int j = 0; j < map[i].size(); ++ j)
            row.append(QString::number(map[i][j]));
        qDebug() << row;
    }

}
开发者ID:redukt0r,项目名称:antling,代码行数:12,代码来源:main.cpp

示例13: handle_player_action

int Gui::handle_player_action(const Point2D &at_position, WorldMap &worldmap)
{
    Rect2D actionButton;
    
    actionButton.pos.x = 387.0f;
    actionButton.pos.y = 228.0f;
    actionButton.width = 61.0f;
    actionButton.height = 61.0f;
    
    Point2D tempPoint = at_position;
    
    if (isPointInRect(&tempPoint, &actionButton))
    {
        int i;
        for (i = 0; i < worldmap.getNPCcounter(); i++)
        {
            if (worldmap.getNPC(i).getIfInPlayerFocus())
            {
                //printf("Player interaction with %s\n", worldmap.getNPC(i).getName());
                this->interactedNPC = &worldmap.getNPC(i);
                return ACTION_NPC;
            }
        }
        for (i = 0; i < worldmap.getObjectCounter(); i++)
        {
            if (worldmap.getObject(i).getIfInPlayerFocus()) {            
                //printf("Player interaction with %s\n", worldmap.getObject(i).getName());
                this->interactedObject = &worldmap.getObject(i);
                return ACTION_OBJECT;
            }
        }
    }
    
    return NO_ACTION;
}
开发者ID:MarkusPfundstein,项目名称:OpenGL-2D-RPG-Engine-iPhone,代码行数:35,代码来源:Gui.cpp

示例14: readFields

void NewClientView::readFields(int length, WorldMap &maps) {
    position pos = viewPosition;
    int x_inc = (stripedir == dir_right) ? 1 : -1;
    int tmp_maxtiles = 1;

    for (int i = 0; i < length; ++i) {
        try {
            Field &field = maps.at(pos);

            if (!field.isTransparent() || field.itemCount() > 0) {
                exists = true;
                mapStripe[i] = &field;
                maxtiles = tmp_maxtiles;
            }
        } catch (FieldNotFound &) {
        }

        ++tmp_maxtiles;
        //increase x due to perspective
        pos.x += x_inc;
        //increase y due to perspective
        ++pos.y;
    }
}
开发者ID:Illarion-eV,项目名称:Illarion-Server,代码行数:24,代码来源:NewClientView.cpp

示例15: DoTick

void PlantScript::DoTick(U32 delta)
{
	// We need process at a steady rate so that
	// the time between ticks is constant.
	// This is performance regressive, so something
	// to keep an eye on.
	static const int MAP2 = MAX_MAP_SIZE*MAX_MAP_SIZE;
	static const int DELTA = 100*1000;	// How frequenty to tick a given plant
	static const int N_PER_MSEC = MAP2 / DELTA;
	static const int GROWTH_CHANCE = 8;
	static const int PRIME = 1553;

	static const float SHADE_EFFECT = 0.7f;

	int n = N_PER_MSEC * delta;
	Weather* weather = Weather::Instance();

	WorldMap* worldMap = context->worldMap;
	Rectangle2I bounds = worldMap->Bounds();
	bounds.Outset(-1);	// edge of map: don't want to tap over the edge.

	const Vector3F& light = context->engine->lighting.direction;
	const float		norm = Max(fabs(light.x), fabs(light.z));
	Vector2I		lightTap = { int(LRintf(light.x / norm)), int(LRintf(light.z / norm)) };
	Census*			census = &context->chitBag->census;

	for (int i = 0; i < n; ++i) {
		index += PRIME;

		int x = IndexToMapX(index);
		int y = IndexToMapY(index);

		const WorldGrid& wg = worldMap->GetWorldGrid(x, y);
		if (!wg.Plant()) continue;

		Vector2I pos2i = { x, y };
		Vector2F pos2f = ToWorld2F(pos2i);

		// --- Light Tap --- //
		const float	height = PlantScript::PlantRes(wg.Plant() - 1, wg.PlantStage())->AABB().SizeY();
		const float	rainBase		= weather->RainFraction(pos2f.x, pos2f.y);
		const float sunBase			= (1.0f - rainBase);
		const float temperatureBase	= weather->Temperature(pos2f.x, pos2f.y);

		float rain			= rainBase;
		float sun			= sunBase;
		float temperature	= temperatureBase;
		float growth		= 1.0f;

		Vector2I tap = pos2i + lightTap;

		// Check for something between us and the light.
		const WorldGrid& wgTap = worldMap->GetWorldGrid(tap);
		float tapHeight = float(wgTap.RockHeight());
		if (wgTap.PlantStage()) {
			tapHeight = PlantScript::PlantRes(wgTap.Plant() - 1, wgTap.PlantStage())->AABB().SizeY();
		}

		if (tapHeight > (height + 0.1f)) {
			// in shade
			sun *= SHADE_EFFECT;
			temperature *= SHADE_EFFECT;
		}

		// ---- Adjacent --- //
		static const int NADJ = 4;
		static const Vector2I check[NADJ] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
		int same = 0;
		for (int i = 0; i<NADJ; ++i) {
			tap = pos2i + check[i];
			const WorldGrid& wgAdj = worldMap->GetWorldGrid(tap.x, tap.y);
			if (wgAdj.Plant() == wg.Plant()) {
				++same;
			}

			if (wgAdj.RockHeight()) {
				// Water or rock runoff increase water.
				rain += 0.25f * rainBase;
			}
			if (wgAdj.IsFluid()) {
				rain += 0.25f;	// just a lot of water.
			}
			if (wgAdj.IsWater()) {
				rain += 0.25f;	// more water
				temperature = Mean(0.5f, temperature); // moderate temperature
			}
		}
		// Nutrient depletion? Too packed in?
		if (same == NADJ) {
			growth *= 0.25f;
		}

		// Are we under water?
		float fluidHeight = wg.FluidHeight();
		if (fluidHeight > 0.01f) {
			// Any amount of water goes to rain 100%
			rain = 1.0f;
			// not sure what to do with temp...assume a little cooler?
			temperature *= 0.8f;

//.........这里部分代码省略.........
开发者ID:fordream,项目名称:alteraorbis,代码行数:101,代码来源:plantscript.cpp


注:本文中的WorldMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。