Ejemplo n.º 1
0
static void
readShadowLayer(Reader &reader, const Table &data,
                int ox, int oy, int w, int h)
{
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
		{
			int16_t value = tableGetWrapped(data, x+ox, y+oy, 3);
			onShadowTile(reader, value & 0xF, x, y);
		}
}
Ejemplo n.º 2
0
	void handleTile(int x, int y, int z)
	{
		int tileInd =
			tableGetWrapped(mapData, x + viewpPos.x, y + viewpPos.y, z);

		/* Check for empty space */
		if (tileInd < 48)
			return;

		int prio = samplePriority(tileInd);

		/* Check for faulty data */
		if (prio == -1)
			return;

		SVVector *targetArray;

		/* Prio 0 tiles are all part of the same ground layer */
		if (prio == 0)
		{
			targetArray = &groundVert;
		}
		else
		{
			int scanInd = y + prio;
			targetArray = &scanrowVert[scanInd];
		}

		/* Check for autotile */
		if (tileInd < 48*8)
		{
			handleAutotile(x, y, tileInd, targetArray);
			return;
		}

		int tsInd = tileInd - 48*8;
		int tileX = tsInd % 8;
		int tileY = tsInd / 8;

		Vec2i texPos = TileAtlas::tileToAtlasCoor(tileX, tileY, atlas.efTilesetH, atlas.size.y);
		FloatRect texRect((float) texPos.x+.5, (float) texPos.y+.5, 31, 31);
		FloatRect posRect(x*32, y*32, 32, 32);

		SVertex v[4];
		Quad::setTexPosRect(v, texRect, posRect);

		for (size_t i = 0; i < 4; ++i)
			targetArray->push_back(v[i]);
	}
Ejemplo n.º 3
0
static void
readLayer(Reader &reader, const Table &data,
          const Table *flags, int ox, int oy, int w, int h, int z)
{
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
		{
			int16_t tileID = tableGetWrapped(data, x+ox, y+oy, z);

			if (tileID <= 0)
				continue;

			onTile(reader, tileID, x, y, flags);
		}
}
Ejemplo n.º 4
0
	bool sampleFlashColor(Vec4 &out, int x, int y)
	{
		int16_t packed = tableGetWrapped(flashData, x, y);

		if (packed == 0)
			return false;

		const float max = 0xF;

		float b = ((packed & 0x000F) >> 0) / max;
		float g = ((packed & 0x00F0) >> 4) / max;
		float r = ((packed & 0x0F00) >> 8) / max;

		out = Vec4(r, g, b, 1);

		return true;
	}