Beispiel #1
0
		void TiledMapLayer::draw(int xOffset, int yOffset) const
		{
			if (!m_visible) { return; }
			// for each height.
			for (unsigned int y = 0; y < m_height; y++)
			{
				// for each width  -- this goes across the map.
				for (unsigned int x = 0; x < m_width; x++)
				{
					//g->setDrawColor(Color::white); 
					//g->drawRect((x * m_tileWidth) + xOffset, (y * m_tileWidth) + yOffset, m_tileWidth, m_tileHeight);

					unsigned int gid = getTileGID(x, y);
					if (gid != 0) {
						TiledMapTileset* tileset = m_map->getTilesetByGID(gid);
						if (tileset != NULL) { 

							Image* t = tileset->getTileByGID(gid)->getImage();
							if (t != NULL) {
								t->setAlpha(m_opacity);
								t->draw((int) (x * tileset->getTileWidth()) + xOffset, (int) (y * tileset->getTileHeight()) + yOffset);
								t->setAlpha(1.0f);
							}
						}
					}
				}
			}
		}
Beispiel #2
0
int ChunkManager::getTileGID(const Vec2 & pos) const
{
	auto chunk = getChunk(pos);
	return chunk? chunk->getTileGID(pos - chunk->getPosition()): -1;
}