Example #1
0
void GrafxDrawBackground(
	GraphicsDevice *g, DrawBuffer *buffer,
	HSV tint, Vec2i pos, GrafxDrawExtra *extra)
{
	Vec2i v;

	DrawBufferSetFromMap(buffer, &gMap, pos, X_TILES);
	DrawBufferDraw(buffer, Vec2iZero(), extra);

	for (v.y = 0; v.y < g->cachedConfig.Res.y; v.y++)
	{
		for (v.x = 0; v.x < g->cachedConfig.Res.x; v.x++)
		{
			DrawPointTint(g, v, tint);
		}
	}
	memcpy(g->bkg, g->buf, GraphicsGetMemSize(&g->cachedConfig));
	memset(g->buf, 0, GraphicsGetMemSize(&g->cachedConfig));
}
Example #2
0
void DrawShadow(GraphicsDevice *device, Vec2i pos, Vec2i size)
{
	Vec2i drawPos;
	HSV tint = { -1.0, 1.0, 0.0 };
	if (!ConfigGetBool(&gConfig, "Game.Shadows"))
	{
		return;
	}
	for (drawPos.y = pos.y - size.y; drawPos.y < pos.y + size.y; drawPos.y++)
	{
		if (drawPos.y >= device->clipping.bottom)
		{
			break;
		}
		if (drawPos.y < device->clipping.top)
		{
			continue;
		}
		for (drawPos.x = pos.x - size.x; drawPos.x < pos.x + size.x; drawPos.x++)
		{
			// Calculate value tint based on distance from center
			Vec2i scaledPos;
			int distance2;
			if (drawPos.x >= device->clipping.right)
			{
				break;
			}
			if (drawPos.x < device->clipping.left)
			{
				continue;
			}
			scaledPos.x = drawPos.x;
			scaledPos.y = (drawPos.y - pos.y) * size.x / size.y + pos.y;
			distance2 = DistanceSquared(scaledPos, pos);
			// Maximum distance is x, so scale distance squared by x squared
			tint.v = CLAMP(distance2 * 1.0 / (size.x*size.x), 0.0, 1.0);
			DrawPointTint(device, drawPos, tint);
		}
	}
}