Source Code (Use browser search to find items of interest.)
Class Index
ksnake'Ball (./kdegames/ksnake/ball.h:10)
class Ball {
public:
Ball(Board *b, PixServer *p);
void nextMove();
void repaint();
void zero();
private:
Board *board;
PixServer *pixServer;
int index;
int hold;
int next;
};
ksnake'Ball::Ball() (./kdegames/ksnake/ball.cpp:16)
Ball::Ball(Board *b, PixServer *p)
{
board = b;
pixServer = p;
int i = BoardWidth+1;
while( !board->isEmpty(i) ) i++;
hold = index = i;
board->set(index, Balle);
next = SE;
}
ksnake'Ball::zero() (./kdegames/ksnake/ball.cpp:28)
void Ball::zero()
{
board->set(index, empty);
pixServer->erase(index);
}
ksnake'Ball::nextMove() (./kdegames/ksnake/ball.cpp:34)
void Ball::nextMove()
{
hold = index;
board->set(hold, empty);
for ( int x = 0; x < 8 ; x++) {
int d = bounce[next][x];
int nextSq = board->getNext(d, index);
if (board->isHead(nextSq) || board->isEmpty(nextSq)) {
next = d;
index = nextSq;
board->set(index, Balle);
break;
}
}
}
ksnake'Ball::repaint() (./kdegames/ksnake/ball.cpp:52)
void Ball::repaint()
{
static int i = 0;
static bool rotate = TRUE;
pixServer->erase(hold);
pixServer->draw(index, BallPix, i);
if (rotate)
if (++i > 3) i=0;
rotate = !rotate;
}