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


C++ TileLayer::getTileIDs方法代码示例

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


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

示例1: isCollisionWithTileRight

bool CollisionObject::isCollisionWithTileRight() {
	// iterate through collision layers
	for (std::vector<TileLayer*>::const_iterator it = m_pCollisionLayers->begin(); it != m_pCollisionLayers->end(); ++it) {
		TileLayer* pTileLayer = (*it);
		std::vector<std::vector<int>> tiles = pTileLayer->getTileIDs();
		// get this layers position
		Vector2D layerPos = pTileLayer->getPosition();
		int x, y, tileColumn, tileRow, tileid = 0;
		// calculate position on tile map
		x = layerPos.getX() / pTileLayer->getTileSize();
		y = layerPos.getY() / pTileLayer->getTileSize();

		if (getVelocity().getX() > 0) //dreta
		{
			tileColumn = ((getPosition().getX() + Camera::Instance()->getPosition().getX() + getWidth()) / pTileLayer->getTileSize());
			tileRow = (getPosition().getY() / pTileLayer->getTileSize());
			tileid = tiles[tileRow+y][tileColumn + x];//Li restem 1 a la y perque quan estiguem asobre la plataforma no ens doni colisio
		}
		if (tileid != 0) // if the tile id not blank then collide
		{
			return true;
		}
	}
	return false;
}
开发者ID:MontseArch,项目名称:BaseCode,代码行数:25,代码来源:CollisionObject.cpp

示例2: checkPlayerTileCollision

void CollisionManager::checkPlayerTileCollision(Player* pPlayer, 
        const std::vector<TileLayer*>& collisionLayers) {
    for(auto it = collisionLayers.begin(); 
            it != collisionLayers.end(); ++it) {
        TileLayer* pTileLayer = (*it);
        std::vector<std::vector<int>> tiles = pTileLayer->getTileIDs();
        
        Vector2D layerPos = pTileLayer->getPosition();
        
        int x, y, tileColumn, tileRow, tileid = 0;
        
        x = layerPos.getX() / pTileLayer->getTileSize();
        y = layerPos.getY() / pTileLayer->getTileSize();
        
        if(pPlayer->getVelocity().getX() >= 0 || pPlayer->getVelocity().getY() >= 0) {
            tileColumn = ((pPlayer->getPosition().getX() + 
                pPlayer->getWidth()) / pTileLayer->getTileSize());
            tileRow = ((pPlayer->getPosition().getY() + 
                pPlayer->getHeight()) / pTileLayer->getTileSize());
            tileid = tiles[tileRow + y][tileColumn + x];
        }
        else if(pPlayer->getVelocity().getX() < 0 || 
                pPlayer->getVelocity().getY() < 0) {
            tileColumn = pPlayer->getPosition().getX() / pTileLayer->getTileSize();
            tileRow = pPlayer->getPosition().getY() / pTileLayer->getTileSize();
            tileid = tiles[tileRow + y][tileColumn + x];
        }
        
        if(tileid != 0) { pPlayer->collision(); }
    }
}
开发者ID:WillSams,项目名称:Alien-Attack-Linux,代码行数:31,代码来源:CollisionManager.cpp

示例3: update

void Level::update()
{
	ObjectLayer * pObjects;
	for (int i = 0; i < m_layers.size(); ++i)
	{
		if (m_pPlayer->getPosition()->getX() + m_pPlayer->getWidth() > 635)
		{
			TileLayer * pTile = dynamic_cast<TileLayer*>(m_layers[i]);
			if (pTile && pTile->getNumColumns() + pTile->getColumnIncrement() < pTile->getTileIDs().at(0).size())
			{
 				pTile->setColumns(20);
				m_pPlayer->setPosition(Vector2D(10, 330));
				BulletHandler::Instance()->clearAll();
				scrollObjects();
			}
			else
			{
				m_pPlayer->setVelocity(Vector2D(0.0, 0.0));
			}
		}
		m_layers[i]->update();
		pObjects = dynamic_cast<ObjectLayer*>(m_layers[i]);
		if (pObjects)
		{
			CollisionManager::Instance()->checkEnemyPlayerBulletCollision(BulletHandler::Instance()->getBulletPlayer(), pObjects->getObjects());
		}
	}
	CollisionManager::Instance()->checkPlayerEnemyBulletCollision(m_pPlayer, BulletHandler::Instance()->getBulletEnemy());
	BulletHandler::Instance()->update();
	if (m_pPlayer->isDead())
	{
		Game::Instance()->getStateMachine()->changeState(new GameOverState());
	}
}
开发者ID:KyryloBR,项目名称:SDLEngine,代码行数:34,代码来源:Level.cpp

示例4: tileCollisions

bool GameObject::tileCollisions(Vector2D pos){
    for(vector<TileLayer*>::iterator i = collisionLayers->begin(); i != collisionLayers->end(); i++){
        TileLayer* tileLayer = (*i);
        vector<vector<int>> tiles = tileLayer->getTileIDs();

        Vector2D layerPos = tileLayer->getPosition();

        int x, y, tileColumn, tileRow, tileid = 0;

        x = layerPos.X() / tileLayer->getTileSize();
        y = layerPos.Y() / tileLayer->getTileSize();

        Vector2D startPos = pos;
        startPos.setX( startPos.X() + 3);
        startPos.setY( startPos.Y() + 4);
        Vector2D endPos(pos.X() + collisionWidth, pos.Y() + collisionHeight - 4);

        for(int i = startPos.X(); i < endPos.X(); i++) {
            for(int j = startPos.Y(); j < endPos.Y(); j++) {
                tileColumn = i / tileLayer->getTileSize();
                tileRow = j / tileLayer->getTileSize();

                tileid = tiles[tileRow + y][tileColumn + x];

                if(tileid != 0) {
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:Laggy44,项目名称:shark-game,代码行数:32,代码来源:GameObject.cpp

示例5: checkCollideTile

bool PlatformerObject::checkCollideTile(Vector2D newPos)
{
    if(newPos.m_y + m_height >= TheGame::Instance()->getGameHeight() - 32)
    {
        return false;
    }
    else
    {
        for(std::vector<TileLayer*>::iterator it = m_pCollisionLayers->begin(); it != m_pCollisionLayers->end(); ++it)
        {
            TileLayer* pTileLayer = (*it);
            std::vector<std::vector<int>> tiles = pTileLayer->getTileIDs();
            
            Vector2D layerPos = pTileLayer->getPosition();
            
            int x, y, tileColumn, tileRow, tileid = 0;
            
            x = layerPos.getX() / pTileLayer->getTileSize();
            y = layerPos.getY() / pTileLayer->getTileSize();
            
            Vector2D startPos = newPos;
            startPos.m_x += 15;
            startPos.m_y += 20;
            Vector2D endPos(newPos.m_x + (m_width - 15), (newPos.m_y) + m_height - 4);
            
            for(int i = startPos.m_x; i < endPos.m_x; i++)
            {
                for(int j = startPos.m_y; j < endPos.m_y; j++)
                {
                    tileColumn = i / pTileLayer->getTileSize();
                    tileRow = j / pTileLayer->getTileSize();
                    
                    tileid = tiles[tileRow + y][tileColumn + x];
                    
                    if(tileid != 0)
                    {
                        return true;
                    }
                }
            }
        }
        
        return false;
        
    }
}
开发者ID:WillSams,项目名称:Conan-the-Caveman-Linux,代码行数:46,代码来源:PlatformerObject.cpp

示例6: checkCollideTile

bool Actor::checkCollideTile(Vector2D newPos)
{
	for (std::vector<TileLayer*>::iterator it = m_pCollisionLayers->begin(); it != m_pCollisionLayers->end(); ++it)
	{
		TileLayer* pTileLayer = (*it);

		//Check in Map Bounds Before We Bother Checking Collision // Otherwise NO Tiles Stupid!
		if (newPos.m_x > 0 && newPos.m_x < pTileLayer->getMapWidth() - 100 && newPos.m_y > 0 && newPos.m_y < pTileLayer->getMapHeight())
		{
			std::vector<std::vector<int>> tiles = pTileLayer->getTileIDs();

			Vector2D layerPos = pTileLayer->getPosition();

			int x, y, tileColumn, tileRow, tileID = 0;

			// get specific tile
			x = layerPos.getX() / pTileLayer->getTileSize();
			y = layerPos.getY() / pTileLayer->getTileSize();

			Vector2D startPos = newPos;
			startPos.m_x;
			startPos.m_y;
			Vector2D endPos(newPos.m_x + (m_width), newPos.m_y + (m_height));

			for (int i = startPos.m_x; i < endPos.m_x; ++i)
			{
				for (int j = startPos.m_y; j < endPos.m_y; ++j)
				{
					tileColumn = i / pTileLayer->getTileSize();
					tileRow = j / pTileLayer->getTileSize();

					tileID = tiles[tileRow + y][tileColumn + x];

					if (tileID != 0)
					{
						return true;
					}
				}
			}
		}

	}

	return false;
}
开发者ID:jandricksen,项目名称:Entropy,代码行数:45,代码来源:Actor.cpp


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