Back to index

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

Sprite that represents a blood "splat" in the water. More...

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

List of all members.

Public Member Functions

 Splat (Screen *screen, QPoint center, int depth)
 Constructor.
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.
virtual void kill ()
 Kills this Sprite.
virtual bool tickUpdate ()
 Called when the current frame expires.

Protected Member Functions

bool timerTick ()
 Increments the animation timer.

Protected Attributes

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

Sprite that represents a blood "splat" in the water.

Definition at line 746 of file aasaver.cpp.


Constructor & Destructor Documentation

Splat::Splat ( Screen screen,
QPoint  center,
int  depth 
) [inline]

Constructor.

Parameters:
screenThe Screen to create the splat in.
centerThe point to center the splat around.
depthThe depth to create the splat at.

Definition at line 756 of file aasaver.cpp.

                                                    :
        Sprite(screen, 0, 0, depth, 450 /* frame Delay */)
    {
        QString splats[] = {
"\n"
"   .\n"
"  ***\n"
"   '\n"
""
,

"\n"
" \",*;`\n"
" \"*,**\n"
" *\"'~'\n"
""
,
"  , ,\n"
" \" \",\"'\n"
" *\" *'\"\n"
"  \" ; .\n"
""
,
"* ' , ' `\n"
"' ` * . '\n"
" ' `' \",'\n"
"* ' \" * .\n"
"\" * ', '"
        };

        for(unsigned i = 0; i < ARRAY_SIZE(splats); ++i)
            addFrame(Frame(splats[i], QString(), 0xB21818, ' '));

        QRect r(center, QSize(9, 5));
        r.moveCenter(center);
        m_x = r.x();
        m_y = r.y();

        setDieAfterLastFrame(true);
    }

Here is the call graph for this function:


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:

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:

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 Sprite::kill ( ) [inline, virtual, inherited]

Kills this Sprite.

The parent Screen will delete this Sprite on the next animation cycle.

Reimplemented in FishSprite, and RandomMovingSprite.

Definition at line 189 of file sprite.h.

    {
        m_isKilled = true;
    }

Here is the caller 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:

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:

bool Sprite::tickUpdate ( ) [virtual, inherited]

Called when the current frame expires.

This function needs to perform any actions necessary to make sure that it is ready to be painted, including calling erase(). You do not need to call paint() from this function.

Returns:
true if the on-screen representation of this Sprite changed, false, otherwise.

Reimplemented in FishSprite, MovingSprite, AirBubble, and Seaweed.

Definition at line 65 of file sprite.cpp.

{
    if (m_frames.size() == 1)
        return false;

    if (!timerTick())
        return false;

    erase();

    ++m_currentFrame;
    if (m_currentFrame == m_frames.size())
    {
        m_currentFrame = 0;

        if(m_killAfterLastFrame)
        {
            erase();
            kill();
        }
    }

    return true;
}

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 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.

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.

Screen* Sprite::m_screen [protected, inherited]

The Screen that we belong to.

Definition at line 51 of file sprite.h.

int Sprite::m_ticksSinceFrameChange [protected, inherited]

Number of timer ticks since we last changed frame.

Definition at line 60 of file sprite.h.

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: