Source Code (Use browser search to find items of interest.)
Class Index
kspaceduel'MobileSprite (./kdegames/kspaceduel/sprites.h:41)
class MobileSprite:public QCanvasSprite
{
public:
MobileSprite(QCanvasPixmapArray* array, QCanvas* canvas, int pn);
virtual void forward(double mult,int frame);
virtual void forward(double mult);
virtual void calculateGravity(double gravity,double mult);
int spriteFieldWidth(){return canvas()->width();}
int spriteFieldHeight(){return canvas()->height();}
AiSprite toAiSprite();
bool isStopped() {return stopped;}
void stop(bool s=true) {stopped=s;}
int getPlayerNumber() {return playerNumber;}
protected:
void checkBounds();
bool stopped;
int playerNumber;
};
kspaceduel'MobileSprite::MobileSprite() (./kdegames/kspaceduel/sprites.cpp:22)
MobileSprite::MobileSprite(QCanvasPixmapArray* seq, QCanvas* canvas, int pn)
:QCanvasSprite(seq, canvas)
{
stopped=false;
playerNumber=pn;
}
kspaceduel'MobileSprite::forward() (./kdegames/kspaceduel/sprites.cpp:29)
void MobileSprite::forward(double mult, int fr)
{
if(!stopped)
{
QCanvasSprite::moveBy(xVelocity()*mult,yVelocity()*mult);
checkBounds();
setFrame(fr);
}
else
setFrame(fr);
}
kspaceduel'MobileSprite::forward() (./kdegames/kspaceduel/sprites.cpp:41)
void MobileSprite::forward(double mult)
{
if(!stopped)
{
QCanvasSprite::moveBy(xVelocity()*mult,yVelocity()*mult);
checkBounds();
}
}
kspaceduel'MobileSprite::checkBounds() (./kdegames/kspaceduel/sprites.cpp:50)
void MobileSprite::checkBounds()
{
double cx, cy;
int ch, cw;
cx = x();
cy = y();
ch = canvas()->height();
cw = canvas()->width();
if ( (int)(cx+0.5) < 0 )
cx = cw - 1 - fmod( -cx, cw );
else if ( (int)(cx+0.5) > ( cw-1 ) )
cx = fmod( cx-cw-1, cw );
if ( (int)(cy+0.5) < 0 )
cy = ch-1 - fmod( -cy, ch );
else if ( (int)(cy+0.5) > ( ch-1 ) )
cy = fmod( cy-ch-1, ch );
if ( (cx != x()) || (cy != y()) )
{
// printf("%5.2f %5.2f %5.2f %5.2f\n", x(), y(), cx, cy);
move( cx, cy );
}
}
kspaceduel'MobileSprite::calculateGravity() (./kdegames/kspaceduel/sprites.cpp:75)
void MobileSprite::calculateGravity(double gravity,double mult)
{
double abs_2,nx,ny,ex,ey,sq,eg;
if(!stopped)
{
ex=x()-canvas()->width()/2.0;
ey=y()-canvas()->height()/2.0;
abs_2=ex*ex+ey*ey;
sq=sqrt(abs_2);
nx=ex/sq;
ny=ey/sq;
eg=gravity*mult;
setVelocity(xVelocity()-eg*nx/abs_2,
yVelocity()-eg*ny/abs_2);
}
}
kspaceduel'MobileSprite::toAiSprite() (./kdegames/kspaceduel/sprites.cpp:95)
AiSprite MobileSprite::toAiSprite()
{
// y direction: screen: bottom to top
// mathematical: top to bottom
AiSprite as;
as.x=x()-canvas()->width()/2.0;
as.y=-(y()-canvas()->height()/2.0);
as.dx=xVelocity();
as.dy=-yVelocity();
as.sun=false;
as.border=false;
return as;
}