Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Member Functions | Protected Attributes
RandomMovingSprite Class Reference

Will spawn a random sprite when killed, otherwise behaves just like MovingSprite. More...

Inheritance diagram for RandomMovingSprite:
Inheritance graph
[legend]
Collaboration diagram for RandomMovingSprite:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RandomMovingSprite (Screen *screen, int direct, double speed, int x, int y, int z)
virtual void kill ()
 Spawns another RandomMovingSprite before dying.
void setFrameTime (int milliseconds)
 Sets the amount of time a frame is shown.
int frameTime () const
 Returns the amount of time a frame lasts in milliseconds.
int direction () const
 Returns the direction the sprite travels in.
double realSpeed () const
 Returns the fractional speed of the sprite.
double realX () const
 Returns the real (fractional) X position of the sprite.
virtual bool tickUpdate ()
 Reimplemented from Sprite::tickUpdate() to handle motion and frame animation.
virtual bool canCollide () const
virtual void collision (Sprite *sprite)
 Called when a collision occurs with any Sprite on-screen if canCollide() returns true.
void addFrame (const Frame &frame)
 Appends a frame of animation to the end of the current list.
void setFrameDelay (int delay)
 Sets the amount of time to show a frame for.
void setDieAfterLastFrame (bool dieAfterLast)
 Sets whether this Sprite should automatically call kill() after the last frame of animation has run.
Screenscreen () const
bool isKilled () const
int depth () const
QRect geom () const
void erase ()
 Erases this Sprite from its Screen, using the current animation frame to form the clear mask.
void paint ()
 Draws this Sprite onto the Screen.

Protected Member Functions

bool timerTick ()
 Increments the animation timer.

Protected Attributes

int m_direct
 Direction to move in, -1 == left, 1 == right.
double m_speed
 Speed to move at (Currently m_speed per tick).
double m_realX
 Used for accuracy, holds fractional x position.
int m_ticksSinceLastChange
 Number of timer ticks since last frame change.
int m_frameTime
 Amount of time in milliseconds to show each frame.
Screenm_screen
 The Screen that we belong to.
int m_currentFrame
 The current frame of animation.
int m_x
 Our current logical x position.
int m_y
 Our current logical y position.
int m_z
 Our current depth.
QVector< Framem_frames
 Array of animation frames.
bool m_isKilled
 True if we've been killed.
bool m_killAfterLastFrame
 True if we should auto-kill after the last frame.
int m_ticksSinceFrameChange
 Number of timer ticks since we last changed frame.
int m_frameDelay
 Number of milliseconds to show a frame for.

Detailed Description

Will spawn a random sprite when killed, otherwise behaves just like MovingSprite.

Definition at line 425 of file aasaver.cpp.


Constructor & Destructor Documentation

RandomMovingSprite::RandomMovingSprite ( Screen screen,
int  direct,
double  speed,
int  x,
int  y,
int  z 
) [inline]

Definition at line 428 of file aasaver.cpp.

                                                                                     :
        MovingSprite(screen, direct, speed, x, y, z)
    {
    }

Member Function Documentation

void Sprite::addFrame ( const Frame frame) [inherited]

Appends a frame of animation to the end of the current list.

Parameters:
frameFrame of animation to add. It should be the same size as the other frames already in the list.

Definition at line 39 of file sprite.cpp.

{
    m_frames.append(frame);
}

Here is the caller graph for this function:

virtual bool Sprite::canCollide ( ) const [inline, virtual, inherited]
Returns:
true if this sprite can be involved in a collision with another Sprite. The other sprite doesn't necessarily have to have this also set to true.

Reimplemented in TeethSprite.

Definition at line 97 of file sprite.h.

{ return false; }

Here is the caller graph for this function:

virtual void Sprite::collision ( Sprite sprite) [inline, virtual, inherited]

Called when a collision occurs with any Sprite on-screen if canCollide() returns true.

Parameters:
spriteThe Sprite that a collision happened with. It is safe to kill() the Sprite, move it, etc.

Reimplemented in TeethSprite.

Definition at line 106 of file sprite.h.

    {
        Q_UNUSED(sprite); // Base class does nothing.
    }

Here is the caller graph for this function:

int Sprite::depth ( ) const [inline, inherited]
Returns:
The depth of the Sprite. 0 is closest to the screen.

Definition at line 161 of file sprite.h.

    {
        return m_z;
    }

Here is the caller graph for this function:

int MovingSprite::direction ( ) const [inline, inherited]

Returns the direction the sprite travels in.

Definition at line 373 of file aasaver.cpp.

    {
        return m_direct;
    }
void Sprite::erase ( ) [inherited]

Erases this Sprite from its Screen, using the current animation frame to form the clear mask.

This should be called before any change which will change the on-screen display of the object, such as motion or animation changes.

Definition at line 44 of file sprite.cpp.

Here is the caller graph for this function:

int MovingSprite::frameTime ( ) const [inline, inherited]

Returns the amount of time a frame lasts in milliseconds.

Definition at line 370 of file aasaver.cpp.

{ return m_frameTime; }
QRect Sprite::geom ( ) const [inherited]
Returns:
The rectangular geometry of this object in the Pixel coordinate system.

Definition at line 90 of file sprite.cpp.

{
    return QRect(m_x, m_y, m_frames[0].width(), m_frames[0].height());
}

Here is the caller graph for this function:

bool Sprite::isKilled ( ) const [inline, inherited]
Returns:
true if this Sprite is dead. If true, it will probably soon be deleted by its Screen.

Definition at line 153 of file sprite.h.

    {
        return m_isKilled;
    }

Here is the caller graph for this function:

virtual void RandomMovingSprite::kill ( ) [inline, virtual]

Spawns another RandomMovingSprite before dying.

Reimplemented from Sprite.

Definition at line 434 of file aasaver.cpp.

Here is the call graph for this function:

void Sprite::paint ( ) [inherited]

Draws this Sprite onto the Screen.

Definition at line 49 of file sprite.cpp.

Here is the caller graph for this function:

double MovingSprite::realSpeed ( ) const [inline, inherited]

Returns the fractional speed of the sprite.

Definition at line 379 of file aasaver.cpp.

    {
        return m_speed;
    }
double MovingSprite::realX ( ) const [inline, inherited]

Returns the real (fractional) X position of the sprite.

Definition at line 385 of file aasaver.cpp.

    {
        return m_realX;
    }

Here is the caller graph for this function:

Screen* Sprite::screen ( ) const [inline, inherited]
Returns:
The Screen this Sprite belongs to.

Definition at line 144 of file sprite.h.

    {
        return m_screen;
    }

Here is the caller graph for this function:

void Sprite::setDieAfterLastFrame ( bool  dieAfterLast) [inline, inherited]

Sets whether this Sprite should automatically call kill() after the last frame of animation has run.

Parameters:
dieAfterLastIf true, this Sprite will automatically call kill() after its last frame has elapsed.

Definition at line 136 of file sprite.h.

    {
        m_killAfterLastFrame = dieAfterLast;
    }

Here is the caller graph for this function:

void Sprite::setFrameDelay ( int  delay) [inline, inherited]

Sets the amount of time to show a frame for.

Parameters:
delayThe frame delay, in milliseconds of time.

Definition at line 124 of file sprite.h.

Here is the caller graph for this function:

void MovingSprite::setFrameTime ( int  milliseconds) [inline, inherited]

Sets the amount of time a frame is shown.

Use this function for MovingSprites that are also animated.

Parameters:
millisecondsAmount of time to show a frame for in milliseconds.

Definition at line 364 of file aasaver.cpp.

    {
        m_frameTime = milliseconds;
    }

Here is the caller graph for this function:

virtual bool MovingSprite::tickUpdate ( ) [inline, virtual, inherited]

Reimplemented from Sprite::tickUpdate() to handle motion and frame animation.

This function will automatically kill() this sprite when it moves off screen. The inherited tickUpdate() is not called.

Reimplemented from Sprite.

Reimplemented in FishSprite.

Definition at line 395 of file aasaver.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Sprite::timerTick ( ) [protected, inherited]

Increments the animation timer.

Returns:
true if time has elapsed past m_frameDelay since the last frame change.

Definition at line 54 of file sprite.cpp.

{
    ++m_ticksSinceFrameChange;
    if (m_ticksSinceFrameChange * m_screen->msPerTick() < m_frameDelay)
        return false;

    //Ring! Ring!
    m_ticksSinceFrameChange = 0;
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

int Sprite::m_currentFrame [protected, inherited]

The current frame of animation.

Definition at line 52 of file sprite.h.

int MovingSprite::m_direct [protected, inherited]

Direction to move in, -1 == left, 1 == right.

Definition at line 330 of file aasaver.cpp.

int Sprite::m_frameDelay [protected, inherited]

Number of milliseconds to show a frame for.

Definition at line 61 of file sprite.h.

QVector<Frame> Sprite::m_frames [protected, inherited]

Array of animation frames.

Definition at line 57 of file sprite.h.

int MovingSprite::m_frameTime [protected, inherited]

Amount of time in milliseconds to show each frame.

Definition at line 334 of file aasaver.cpp.

bool Sprite::m_isKilled [protected, inherited]

True if we've been killed.

Definition at line 58 of file sprite.h.

bool Sprite::m_killAfterLastFrame [protected, inherited]

True if we should auto-kill after the last frame.

Definition at line 59 of file sprite.h.

double MovingSprite::m_realX [protected, inherited]

Used for accuracy, holds fractional x position.

Definition at line 332 of file aasaver.cpp.

Screen* Sprite::m_screen [protected, inherited]

The Screen that we belong to.

Definition at line 51 of file sprite.h.

double MovingSprite::m_speed [protected, inherited]

Speed to move at (Currently m_speed per tick).

Definition at line 331 of file aasaver.cpp.

int Sprite::m_ticksSinceFrameChange [protected, inherited]

Number of timer ticks since we last changed frame.

Definition at line 60 of file sprite.h.

int MovingSprite::m_ticksSinceLastChange [protected, inherited]

Number of timer ticks since last frame change.

Definition at line 333 of file aasaver.cpp.

int Sprite::m_x [protected, inherited]

Our current logical x position.

Definition at line 53 of file sprite.h.

int Sprite::m_y [protected, inherited]

Our current logical y position.

Definition at line 54 of file sprite.h.

int Sprite::m_z [protected, inherited]

Our current depth.

Definition at line 55 of file sprite.h.


The documentation for this class was generated from the following file: