示例#1
0
void PuzzlesDraw(const Puzzle & pzl, const Surface & sf, s16 dstx, s16 dsty)
{
    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();

    // show all for debug
    if(IS_DEVEL()) return;

    u8 alpha = 250;
    u32 ticket = 0;
    LocalEvent & le = LocalEvent::Get();
    while(le.HandleEvents() && 0 < alpha)
    {
        if(Game::ShouldAnimateInfrequent(ticket, 1))
        {
    	    cursor.Hide();
	    display.Blit(sf, dstx, dsty);
	    for(size_t ii = 0; ii < pzl.size(); ++ii)
	    {
    		const Sprite & piece = AGG::GetICN(ICN::PUZZLE, ii);
		if(pzl.test(ii))
		{
		    Surface fade(piece.w(), piece.h());
		    fade.SetColorKey();
		    fade.Blit(piece);
		    fade.SetAlpha(alpha);
		    if(Settings::Get().QVGA())
		    display.Blit(fade, dstx + 8 + piece.x() - BORDERWIDTH, dsty + 8 + piece.y() - BORDERWIDTH);
		    else
		    display.Blit(fade, dstx + piece.x() - BORDERWIDTH, dsty + piece.y() - BORDERWIDTH);
		}
		else
		{
		    if(Settings::Get().QVGA())
		    display.Blit(piece, dstx + 8 + piece.x() - BORDERWIDTH, dsty + 8 + piece.y() - BORDERWIDTH);
		    else
		    display.Blit(piece, dstx + piece.x() - BORDERWIDTH, dsty + piece.y() - BORDERWIDTH);
		}
	    }
	    cursor.Show();
    	    display.Flip();
    	    alpha -= 10;
	}

	++ticket;
    }
    cursor.Hide();
}
示例#2
0
void ZoneOpenRandomTiles(Puzzle & pzl, u8 & opens, const u8* it1, const u8* it2)
{
    std::vector<u8> values;
    values.reserve(25);
    const u8* it = NULL;

    while(opens)
    {
	values.clear();
	it = it1;
	while(it && it2 && it <= it2){ if(! pzl.test(*it)) values.push_back(*it); ++it; }
	if(values.empty()) break;
	pzl.set(*Rand::Get(values));
	--opens;
    }
}
示例#3
0
bool ClosedTilesExists(const Puzzle & pzl, const u8* it1, const u8* it2)
{
    while(it1 && it2 && it1 <= it2) if(! pzl.test(*it1++)) return true;
    return false;
}