Ejemplo n.º 1
0
/* draw simple cursor */
void Cursor::DrawCursor(Surface &surface, const u8 indexcolor, bool solid)
{
    if(! surface.isValid()) return;

    surface.SetColorKey();

    u16 width  = surface.w();
    u16 height = surface.h();

    // draw cursor
    u32 color = surface.GetColor(indexcolor);
    surface.Lock();
    if(solid)
    {
	for(u8 i = 0; i < width; ++i)
        {
    	    surface.SetPixel(i, 0, color);
            surface.SetPixel(i, height - 1, color);
        }

        for(u8 i = 0; i < height; ++i)
        {
            surface.SetPixel(0, i, color);
    	    surface.SetPixel(width - 1, i, color);
        }
    }
    else
    {
	for(u8 i = 0; i < width; ++i)
	{
    	    surface.SetPixel(i, 0, color);
    	    if(i + 1 < width) surface.SetPixel(i + 1, 0, color);
    	    i += 3;
	}
	for(u8 i = 0; i < width; ++i)
	{
    	    surface.SetPixel(i, height - 1, color);
    	    if(i + 1 < width) surface.SetPixel(i + 1, height - 1, color);
    	    i += 3;
	}
	for(u8 i = 0; i < height; ++i)
	{
    	    surface.SetPixel(0, i, color);
    	    if(i + 1 < height) surface.SetPixel(0, i + 1, color);
    	    i += 3;
	}
	for(u8 i = 0; i < height; ++i)
	{
    	    surface.SetPixel(width - 1, i, color);
    	    if(i + 1 < height) surface.SetPixel(width - 1, i + 1, color);
    	    i += 3;
	}
    }
    surface.Unlock();
}