Source Code (Use browser search to find items of interest.)

Class Index

ksnake'Basket (./kdegames/ksnake/basket.h:33)

class Basket : public QObject
{
    Q_OBJECT
public:
    Basket(Board *b, PixServer *p);
    void repaint(bool);
    void newApples();
    void clear();
    Fruits eaten( int i);
signals:
    void openGate();
private:
    Board   *board;
    PixServer *pixServer;
    QList<Kaffee> *list;
    KRandomSequence random;
};

ksnake'Basket::Basket() (./kdegames/ksnake/basket.cpp:26)

Basket::Basket(Board *b, PixServer *p)
{
    board = b;
    pixServer = p;
    list = new QList<Kaffee>;
    list->setAutoDelete( TRUE );
}


ksnake'Basket::clear() (./kdegames/ksnake/basket.cpp:34)

void Basket::clear()
{
    if( !list->isEmpty())
	list->clear();
}


ksnake'Basket::newApples() (./kdegames/ksnake/basket.cpp:40)

void Basket::newApples()
{
    int x;
    int i = 0;

    while(i < 10) {
	x =  random.getLong(board->size());
	if ((unsigned)x < board->size() && board->isEmpty(x) && x > BoardWidth+4) {
	    Kaffee *g = new Kaffee(x, random.getLong(40000), random.getLong(40000));
	    board->set(x, Apple);
	    list->append(g);
	    i++;
	}
    }
}


ksnake'Basket::repaint() (./kdegames/ksnake/basket.cpp:56)

void Basket::repaint(bool dirty )
{
    Kaffee *g;
    for ( g  = list->first(); g != 0; g = list->next()) {
	if (dirty) {
	    pixServer->draw(g->position(), ApplePix, (int)g->type());
	    if (g->dirty)
		g->dirty = FALSE;
	}
	else
	    if (g->dirty) {
		pixServer->draw(g->position(), ApplePix, (int)g->type());
		g->dirty = FALSE;
	    }
    }
}


ksnake'Basket::eaten() (./kdegames/ksnake/basket.cpp:73)

Fruits Basket::eaten(int i)
{
    Kaffee *g;
    Fruits f = Red;

    for (g = list->first(); g != 0; g = list->next() )
	{
	    if (g->position() == i) {
		f = g->type();
		list->remove(g);
		break;
	    }
	}
    if (list->isEmpty())
	emit openGate();

    return f;
}