當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetTile函數代碼示例

本文整理匯總了C++中GetTile函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetTile函數的具體用法?C++ GetTile怎麽用?C++ GetTile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetTile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: GetTile

void CApp::OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle)
{
    if (Left)
    {
        if(!(mX < TileWindow.Width && mY < TileWindow.Height))
        {
            if(InBounds(mX, mY))
            {
                GetTile( mX, mY);
                Map->SetTile(tile, newTileID, newTypeID);
            }
        }
    }
    if (Right)
    {
        if(!(mX < TileWindow.Width && mY < TileWindow.Height))
        {
            if(InBounds(mX, mY))
            {
                if( ((mX - CCamera::CameraControl.GetX()) < MAP_WIDTH*TILE_SIZE*CArea::AreaControl.areaWidth) &&
                        ((mY - CCamera::CameraControl.GetY()) < MAP_HEIGHT*TILE_SIZE*CArea::AreaControl.areaHeight) &&
                        ((mYold - CCamera::CameraControl.GetY()) < MAP_HEIGHT*TILE_SIZE*CArea::AreaControl.areaHeight) &&
                        ((mXold - CCamera::CameraControl.GetX()) < MAP_WIDTH*TILE_SIZE*CArea::AreaControl.areaWidth))
                {
                    // draws tiles but doesn't erase when you go too far
                    GetTile( mX, mYold);
                    Map->SetTile(tile, newTileID, newTypeID);
                    GetTile(mXold, mY);
                    Map->SetTile(tile, newTileID, newTypeID);
                }
            }
        }
    }
}
開發者ID:leenephi,項目名稱:GameLearning_LevelEditor,代碼行數:34,代碼來源:CApp_OnEvent.cpp

示例2: GetTile

    void PathNode::DebugDraw(Label* aLabel, Rect* aRect)
    {
#if DEBUG
        //Draw the rect, the color represent which list the path node is in
        aRect->SetLocalPosition(GetTile()->GetCenter(false));
        aRect->SetSize(GetTile()->GetSize(), GetTile()->GetSize());
        aRect->Draw();

        //Draw the F score
        stringstream ss;
        ss << GetScoreF();
        aLabel->SetText(ss.str());
        aLabel->SetAnchorPoint(0.0f, 1.0f);
        aLabel->SetLocalPosition(vec2(GetTile()->GetLocalX(), GetTile()->GetLocalY() + GetTile()->GetSize()));
        aLabel->Draw();
        
        //Draw the S score
        ss.str("");
        ss << GetScoreG();
        aLabel->SetText(ss.str());
        aLabel->SetAnchorPoint(0.0f, 0.0f);
        aLabel->SetLocalPosition(vec2(GetTile()->GetLocalX(), GetTile()->GetLocalY()));
        aLabel->Draw();
        
        //Draw the H score
        ss.str("");
        ss << GetScoreH();
        aLabel->SetText(ss.str());
        aLabel->SetAnchorPoint(1.0f, 0.0f);
        aLabel->SetLocalPosition(vec2(GetTile()->GetLocalX() + GetTile()->GetSize(), GetTile()->GetLocalY()));
        aLabel->Draw();
#endif
    }
開發者ID:Epidilius,項目名稱:ZeldaStyleAdventureGame,代碼行數:33,代碼來源:PathNode.cpp

示例3: distance

int CCollision::IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
	float d = distance(Pos0, Pos1);
	vec2 Last = Pos0;

	for(float f = 0; f < d; f++)
	{
		float a = f/d;
		vec2 Pos = mix(Pos0, Pos1, a);
		if(IsSolid(round_to_int(Pos.x), round_to_int(Pos.y)) || (!GetTile(round_to_int(Pos.x), round_to_int(Pos.y)) && !GetFTile(round_to_int(Pos.x), round_to_int(Pos.y))))
		{
			if(pOutCollision)
				*pOutCollision = Pos;
			if(pOutBeforeCollision)
				*pOutBeforeCollision = Last;
			if(!GetTile(round_to_int(Pos.x), round_to_int(Pos.y)) && !GetFTile(round_to_int(Pos.x), round_to_int(Pos.y)))
				return -1;
			else
				if (!GetTile(round_to_int(Pos.x), round_to_int(Pos.y))) return GetTile(round_to_int(Pos.x), round_to_int(Pos.y));
				else return GetFTile(round_to_int(Pos.x), round_to_int(Pos.y));
		}
		Last = Pos;
	}
	if(pOutCollision)
		*pOutCollision = Pos1;
	if(pOutBeforeCollision)
		*pOutBeforeCollision = Pos1;
	return 0;
}
開發者ID:Ryozuki,項目名稱:ddnet,代碼行數:29,代碼來源:collision.cpp

示例4: GetTile

/*	Generate a tile type for the specific tile based on surrounding tiles height. */
TerrainTest::tiletype TerrainTest::GetTileType(int x, int y)
{
	tile* t = GetTile(x, y);
	if (!t) return TILE_INVALID;

	//Get height values of surrounding tiles
	int n = -1, s = -1, e = -1, w = -1, se = -1, sw = -1, ne = -1, nw = -1;
	int c = t->height;
	
	tile* t2;
	t2 = GetTile(x, y-1); if (t2) n = t2->height;
	t2 = GetTile(x, y+1); if (t2) s = t2->height;
	t2 = GetTile(x-1, y); if (t2) w = t2->height;
	t2 = GetTile(x+1, y); if (t2) e = t2->height;
	t2 = GetTile(x-1, y-1); if (t2) nw = t2->height;
	t2 = GetTile(x+1, y-1); if (t2) ne = t2->height;
	t2 = GetTile(x-1, y+1); if (t2) sw = t2->height;
	t2 = GetTile(x+1, y+1); if (t2) se = t2->height;
	
	//Use surrounding heights to determine our own type
	if (e == c && w == c && n >= c && s < c && s != -1)
		return TILE_SOUTHEDGE;
	
	if (w >= c && e < c && e != -1 && n == c && s == c)
		return TILE_EASTEDGE;
		
	if (e >= c && w < c && w != -1 && n == c && s == c)
		return TILE_WESTEDGE;
	
	if (e == c && w == c && s >= c && n < c && n != -1)
		return TILE_NORTHEDGE;

	if (e < c && n < c && e != -1 && n != -1 && s >= c && w >= c)
		return TILE_NEEDGE;
	
	if (w < c && n < c && w != -1 && n != -1 && s >= c && e >= c)
		return TILE_NWEDGE;
	
	if (e < c && s < c && e != -1 && s != -1 && n >= c && w >= c)
		return TILE_SEEDGE;
	
	if (w < c && s < c && w != -1 && s != -1 && n >= c && e >= c)
		return TILE_SWEDGE;
	
	//Fix diagonals
	if (n == c && e == c && ne < c && ne != -1)
		return TILE_SWBEND;
		
	if (n == c && w == c && nw < c && nw != -1)
		return TILE_SEBEND;
	
	if (s == c && e == c && se < c && se != -1)
		return TILE_NWBEND;
		
	if (s == c && w == c && sw < c && sw != -1)
		return TILE_NEBEND;

	return TILE_INVALID;
}
開發者ID:McManning,項目名稱:fro_client,代碼行數:60,代碼來源:TerrainTest.cpp

示例5: checkMapCollision

int checkMapCollision(int x, int y, int testX, int testY){
	testY -= 1;
	if(GetTile(30,((x+testX)/8), ((y+testY)/8)) == 0){
		return 1;
	}
	if(GetTile(30, ((x+testX)/8), ((y+testY)/8)) >= 21 
	&& GetTile(30, ((x+testX)/8), ((y+testY)/8)) <= 25){
		return 1;
	}
	if(GetTile(30, ((x+testX)/8), ((y+testY)/8)) >= 16 
	&& GetTile(30, ((x+testX)/8), ((y+testY)/8)) <= 20){
		return 2;
	}
	return 0;
}
開發者ID:Peter-black,項目名稱:SuperCrateBox-GBA,代碼行數:15,代碼來源:main.cpp

示例6: switch

void Map::ShipOccupy(int x, int y, Direction dir, Ship* ship)
{
	int deltaX = 0;
	int deltaY = 0;
	switch (dir)
	{
	case DIR_UP:
		deltaY = 1;
		break;
	case DIR_DOWN:
		deltaY = -1;
		break;
	case DIR_LEFT:
		deltaX = -1;
		break;
	case DIR_RIGHT:
		deltaX = 1;
		break;
	}

	for (int i = 0; i < ship->GetSize(); ++i)
	{
		Tile* tile = GetTile(x, y);
		_ASSERT(tile != nullptr);
		tile->SetOccupiedShip(ship);
		x += deltaX;
		y += deltaY;
	}
}
開發者ID:atgchan,項目名稱:BattleShip,代碼行數:29,代碼來源:Map.cpp

示例7: SynthesizeFrame

// Create a whole 'frame' from VP8 (+ alpha) or lossless.
static int SynthesizeFrame(const WebPDemuxer* const dmux,
                           const Frame* const first_frame,
                           int tile_num, WebPIterator* const iter) {
  const uint8_t* const mem_buf = dmux->mem_.buf_;
  int num_tiles;
  size_t payload_size = 0;
  const Frame* const tile = GetTile(first_frame, tile_num, &num_tiles);
  const uint8_t* const payload = GetFramePayload(mem_buf, tile, &payload_size);
  if (payload == NULL) return 0;

  iter->frame_num_   = first_frame->frame_num_;
  iter->num_frames_  = dmux->num_frames_;
  iter->tile_num_    = tile_num;
  iter->num_tiles_   = num_tiles;
  iter->x_offset_    = tile->x_offset_;
  iter->y_offset_    = tile->y_offset_;
  iter->width_       = tile->width_;
  iter->height_      = tile->height_;
  iter->duration_    = tile->duration_;
  iter->complete_    = tile->complete_;
  iter->tile_.bytes_ = payload;
  iter->tile_.size_  = payload_size;
  // TODO(jzern): adjust offsets for 'TILE's embedded in 'FRM 's
  return 1;
}
開發者ID:ansgri,項目名稱:rsdt-students,代碼行數:26,代碼來源:demux.c

示例8: Progress

void TERRAIN::CalculateAlphaMaps()
{
	Progress("Creating Alpha Map", 0.0f);

	//Clear old alpha maps
	if(m_pAlphaMap != NULL)
		m_pAlphaMap->Release();

	//Create new alpha map
	D3DXCreateTexture(m_pDevice, 128, 128, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pAlphaMap);

	//Lock the texture
	D3DLOCKED_RECT sRect;
	m_pAlphaMap->LockRect(0, &sRect, NULL, NULL);
	BYTE *bytes = (BYTE*)sRect.pBits;
	memset(bytes, 0, 128*sRect.Pitch);		//Clear texture to black

	for(int i=0;i<(int)m_diffuseMaps.size();i++)
		for(int y=0;y<sRect.Pitch / 4;y++)
			for(int x=0;x<sRect.Pitch / 4;x++)
			{
				int terrain_x = (int)(m_size.x * (x / (float)(sRect.Pitch / 4.0f)));
				int terrain_y = (int)(m_size.y * (y / (float)(sRect.Pitch / 4.0f)));
				MAPTILE *tile = GetTile(terrain_x, terrain_y);

				if(tile != NULL && tile->m_type == i)
					bytes[y * sRect.Pitch + x * 4 + i] = 255;
			}

	//Unlock the texture
	m_pAlphaMap->UnlockRect(0);
	
	//D3DXSaveTextureToFile("alpha.bmp", D3DXIFF_BMP, m_pAlphaMap, NULL);
}
開發者ID:Alriightyman,項目名稱:RTS,代碼行數:34,代碼來源:terrain.cpp

示例9: PL_ASSERT

void TileGroup::SetValue(type::Value &value, oid_t tuple_id,
                         oid_t column_id) {
  PL_ASSERT(tuple_id < GetNextTupleSlot());
  oid_t tile_column_id, tile_offset;
  LocateTileAndColumn(column_id, tile_offset, tile_column_id);
  GetTile(tile_offset)->SetValue(value, tuple_id, tile_column_id);
}
開發者ID:foche,項目名稱:peloton,代碼行數:7,代碼來源:tile_group.cpp

示例10: GetTile

peloton::VarlenPool *TileGroup::GetTilePool(const oid_t tile_id) const {
  Tile *tile = GetTile(tile_id);

  if (tile != nullptr) return tile->GetPool();

  return nullptr;
}
開發者ID:jackylk,項目名稱:iso_peloton,代碼行數:7,代碼來源:tile_group.cpp

示例11: while

bool Layer::DrawTileToVertexArrays(VertexVector* vertices, unsigned int x, unsigned int y) const {
	int tileX = x, tileY = y;
	if (IsWidthTiled) { //this stuff can probably be optimized a bit by checking at some higher level?
		if (tileX >= RealWidth)
			tileX %= RealWidth;
		else while (tileX < 0)
			tileX += RealWidth;
	}
	else if (tileX < 0 || tileX >= RealWidth)
		return false;
	if (IsHeightTiled) {
		if (tileY >= Height)
			tileY %= Height;
		else while (tileY < 0)
			tileY += Height;
	}
	else if (tileY < 0 || tileY >= Height)
		return false;
	const Tile tile = GetTile(tileX, tileY);
	if (tile.ID == 0)
		return false;
	quad tileQuad(LevelPtr->QuadsPerTile, tile);
	tileQuad.positionPositionAt(x * TILEWIDTH, y * TILEHEIGHT);
	tileQuad.appendTo(vertices[tileQuad.TextureID]);
	return tile.ID >= LevelPtr->AnimOffset;
}
開發者ID:Violet-CLM,項目名稱:Bunny-Game,代碼行數:26,代碼來源:Layer.cpp

示例12: LOG_TRACE

/**
 * Grab next slot (thread-safe) and fill in the tuple
 *
 * Returns slot where inserted (INVALID_ID if not inserted)
 */
void TileGroup::CopyTuple(const Tuple *tuple, const oid_t &tuple_slot_id) {
    LOG_TRACE("Tile Group Id :: %u status :: %u out of %u slots ", tile_group_id,
              tuple_slot_id, num_tuple_slots);

    oid_t tile_column_count;
    oid_t column_itr = 0;

    for (oid_t tile_itr = 0; tile_itr < tile_count; tile_itr++) {
        const catalog::Schema &schema = tile_schemas[tile_itr];
        tile_column_count = schema.GetColumnCount();

        storage::Tile *tile = GetTile(tile_itr);
        PL_ASSERT(tile);
        char *tile_tuple_location = tile->GetTupleLocation(tuple_slot_id);
        PL_ASSERT(tile_tuple_location);

        // NOTE:: Only a tuple wrapper
        storage::Tuple tile_tuple(&schema, tile_tuple_location);

        for (oid_t tile_column_itr = 0; tile_column_itr < tile_column_count;
                tile_column_itr++) {
            tile_tuple.SetValue(tile_column_itr, tuple->GetValue(column_itr),
                                tile->GetPool());
            column_itr++;
        }
    }
}
開發者ID:tarunbansal,項目名稱:peloton,代碼行數:32,代碼來源:tile_group.cpp

示例13: GetTile

 /// \brief
 ///  Accesses tile by height sample indices inside this sector. Indices must be in valid range
 inline VSectorTile *GetTileAtSampleIndices(int x,int y) const
 {
   x/=m_Config.m_iHeightSamplesPerTile[0];
   y/=m_Config.m_iHeightSamplesPerTile[1];
   // the height samples must be in range, but clamp at max edge because of extra overlapping values
   return GetTile(hkvMath::Min(x,m_Config.m_iTilesPerSector[0]-1),hkvMath::Min(y,m_Config.m_iTilesPerSector[1]-1));
 }
開發者ID:RexBaribal,項目名稱:projectanarchy,代碼行數:9,代碼來源:TerrainSector.hpp

示例14: GetTile

	cTile* cTileMapLineIt::Next()
	{
		GetTile();

      	mbUpdated = false;
		return mpTile;
	}
開發者ID:ArchyInf,項目名稱:HPL1Engine,代碼行數:7,代碼來源:TileMapLineIt.cpp

示例15: coord

void Map::Draw(Gdiplus::Graphics* g)
{
	Vector3i northWestTile = mMapViewport->GetNorthWestTileCoordinate();
	Vector3i southEastTile = mMapViewport->GetSouthEastTileCoordinate();
	Vector2i origin = mMapViewport->GetTileOrigin(northWestTile);
	int xTileCount = southEastTile.GetX() - northWestTile.GetX() + 1;
	int yTileCount = southEastTile.GetY() - northWestTile.GetY() + 1;
	int tileCount = xTileCount*yTileCount;

	for(int i = 0; i<xTileCount; i++)
	{
		for(int j = 0; j<yTileCount; j++)
		{
			Vector3i coord(northWestTile.GetX() + i, northWestTile.GetY() + j, mMapViewport->GetZoom());
			Tile* tile = GetTile(coord);
			if(!tile->IsLoaded())
			{
				tile->SignalReady += [this](Tile* tile) {
					std::lock_guard<std::mutex> lock(signal_mutex);
					SignalNewTile.emit();
				};
				continue;
			}
			Gdiplus::Image* im = tile->GetImage();
			if(im)
				g->DrawImage(im, origin.GetX() + i*mMapSource->GetTileSize(), origin.GetY() + j*mMapSource->GetTileSize());
		}
	}
}
開發者ID:Eisenheim9,項目名稱:MultiTracks,代碼行數:29,代碼來源:Map.cpp


注:本文中的GetTile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。