Back to index

kdeartwork  4.3.2
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
AASaver Class Reference

The main class for the Asciiquarium screensaver. More...

#include <aasaver.h>

Collaboration diagram for AASaver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AASaver (WId id)
 Construct the screensaver with window id id.
QString randColor (QString color_mask)
 Returns a QString holding a color mask, created by choosing random colors to replace numbers in color_mask.
double doubleRand (int max)
void addCastle ()
 Adds the castle sprite to the screen.
void addEnvironment ()
 Adds the environment (sea, etc.) to the screen.
void addAllSeaweed ()
 Adds the seaweed to the screen.
void addAllFish ()
 Adds the initial layout of fish to the sea, scaling the number of fish based on the current screen size.
void addSeaweed (Screen *screen)
 Adds a seaweed to a random position of the sea bottom.
SpritenewFish (Screen *screen)
 Returns a new fish sprite, which has not yet been added to a screen.
void addFish (Screen *screen)
 Adds a new fish sprite to screen.
void addBubble (Screen *screen, int x, int y, int z)
 Adds a new air bubble sprite to screen.
void addNessie (Screen *screen)
 Adds a Nessie, the Loch Ness Monster sprite to screen.
void addBigFish (Screen *screen)
 Adds a big fish sprite to screen.
void addWhale (Screen *screen)
 Adds a whale sprite to screen.
void addShark (Screen *screen)
 Adds a shark sprite to screen.
void addShip (Screen *screen)
 Adds a ship sprite to screen.
void addRandom (Screen *screen)
 Adds a random object from the set (Shark, Big Fish, Nessie, Whale, Ship) to the sea.
virtual void paintEvent (QPaintEvent *pe)
 Reimplemented to update the widget when it gets dirty.

Static Public Member Functions

static AASaverinstance ()

Private Attributes

Screenscreen
 Handles the animation and drawing.
KRandomSequence m_randomSequence
 Randomizes the sequence of fish, seaweeds, colors, etc.

Static Private Attributes

static AASaverm_instance = 0
 Static singleton instance.

Detailed Description

The main class for the Asciiquarium screensaver.

Definition at line 72 of file aasaver.h.


Constructor & Destructor Documentation

AASaver::AASaver ( WId  id)

Construct the screensaver with window id id.

Definition at line 62 of file aasaver.cpp.

                      : KScreenSaver(id)
{
    if(m_instance)
        std::abort();

    m_instance = this;

    screen = new Screen(this);

    addEnvironment();
    addCastle();
    addAllSeaweed();
    addAllFish();
    addRandom(screen);

    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);
    setAttribute(Qt::WA_PaintOnScreen);
    update(rect());
}

Here is the call graph for this function:


Member Function Documentation

Adds the initial layout of fish to the sea, scaling the number of fish based on the current screen size.

Definition at line 494 of file aasaver.cpp.

{
    // Determine how many logical pixels we are dealing with, and find out how
    // many we'd be dealing with in full screen, and then scale the user's
    // number down to adjust so that we look about the same in a window as we
    // do fullscreen. TODO: Xinerama issues?
    QRect fullScreenGeometry(QApplication::desktop()->screenGeometry());

    int full_width = fullScreenGeometry.width() / screen->cellWidth();
    int full_height = fullScreenGeometry.height() / screen->cellHeight() - 9;
    int full_size = full_width * full_height;
    int screen_size = (screen->height() - 9) * screen->width();

    int fish_count = AASaverConfig::fishCount() * screen_size / full_size;
    if(fish_count < 5)
        fish_count = 5;

    for (int i = 1; i <= fish_count; ++ i)
        addFish(screen);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Adds the seaweed to the screen.

Definition at line 174 of file aasaver.cpp.

{
    // figure out how many seaweed to add by the width of the screen
    int seaweed_count = int(screen->width() / 15.0);
    for (int i = 1; i <= seaweed_count; ++i)
        addSeaweed(screen);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addBigFish ( Screen screen)

Adds a big fish sprite to screen.

Parameters:
screenThe Screen to add the big fish to.

Definition at line 1068 of file aasaver.cpp.

{
    QString big_fish_image[] = {
" ______\n"
"`\"\"-.  `````-----.....__\n"
"     `.  .      .       `-.\n"
"       :     .     .       `.\n"
" ,{}{}?:   .    .          _ :\n"
": `.{}?:                  (@) `._\n"
" `. `..'     .     =`-.       .__)\n"
"   ;     .        =  ~  :     .-\"\n"
" .' .'`.   .    .  =.-'  `._ .'\n"
": .'{}?:               .   .'\n"
" '{}?.'  .    .     .   .-'\n"
"   .'____....----''.'=.'\n"
"   \"\"{}{}{}{}{}{}?.'.'\n"
"               ''\"'`",

" 111111\n"
"11111  11111111111111111\n"
"     11  2      2       111\n"
"       1     2     2       11\n"
" 1     1   2    2          1 1\n"
"1 11   1                  1W1 111\n"
" 11 1111     2     1111       1111\n"
"   1     2        1  1  1     111\n"
" 11 1111   2    2  1111  111 11\n"
"1 11   1               2   11\n"
" 1   11  2    2     2   111\n"
"   111111111111111111111\n"
"   11             1111\n"
"               11111",

"                           ______\n"
"          __.....-----'''''  .-\"\"'\n"
"       .-'       .      .  .'\n"
"     .'       .     .     :\n"
"    : _          .    .   :{}{}?,\n"
" _.' (@)                  :{}?.' :\n"
"(__.       .-'=     .     `..' .'\n"
" \"-.     :  ~  =        .     ;\n"
"   `. _.'  `-.=  .    .   .'`. `.\n"
"     `.   .               :{}?`. :\n"
"       `-.   .     .    .  `.{}?`\n"
"          `.=`.``----....____`.\n"
"            `.`.{}{}{}{}{}{}?\"\"\n"
"              '`\"``",

"                           111111\n"
"          11111111111111111  11111\n"
"       111       2      2  11\n"
"     11       2     2     1\n"
"    1 1          2    2   1     1\n"
" 111 1W1                  1   11 1\n"
"1111       1111     2     1111 11\n"
" 111     1  1  1        2     1\n"
"   11 111  1111  2    2   1111 11\n"
"     11   2               1   11 1\n"
"       111   2     2    2  11   1\n"
"          111111111111111111111\n"
"            1111             11\n"
"              11111"
    };

    int big_fish_num = m_randomSequence.getLong(2); // right = 0, left = 1

    int maxHeight = 9, minHeight = screen->height() - 15;
    int y = m_randomSequence.getLong(minHeight - maxHeight) + maxHeight;
    int x = -34, dir = 1;

    if(big_fish_num == 1)
    {
        x = screen->width() - 1;
        dir = -1;
    }

    QString colors = randColor(big_fish_image[2 * big_fish_num + 1]);
    RandomMovingSprite *bigFish = new RandomMovingSprite(screen, dir, 3.0, x, y, 2);
    bigFish->addFrame(Frame(big_fish_image[2 * big_fish_num], colors, 0xFFFF54));

    screen->addSprite(bigFish);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addBubble ( Screen screen,
int  x,
int  y,
int  z 
)

Adds a new air bubble sprite to screen.

The x, y, and z coordinates are all in logical coordinates.

Parameters:
screenThe Screen to add the bubble to.
xThe x position to start the bubble at.
yThe y position to start the bubble at.
zThe z position to start the bubble at.

Definition at line 912 of file aasaver.cpp.

{
    screen->addSprite(new AirBubble(screen, x, y, z));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Adds the castle sprite to the screen.

Definition at line 107 of file aasaver.cpp.

{
    QString castle_image =
            "               T~~\n"
            "               |\n"
            "              /^\\\n"
            "             /   \\\n"
            " _   _   _  /     \\  _   _   _\n"
            "[ ]_[ ]_[ ]/ _   _ \\[ ]_[ ]_[ ]\n"
            "|_=__-_ =_|_[ ]_[ ]_|_=-___-__|\n"
            " | _- =  | =_ = _    |= _=   |\n"
            " |= -[]  |- = _ =    |_-=_[] |\n"
            " | =_    |= - ___    | =_ =  |\n"
            " |=  []- |-  /| |\\   |=_ =[] |\n"
            " |- =_   | =| | | |  |- = -  |\n"
            " |_______|__|_|_|_|__|_______|\n";


    QString castle_mask =
        "                RR\n"
        "\n"
        "              yyy\n"
        "             y   y\n"
        "            y     y\n"
        "           y       y\n"
        "\n"
        "\n"
        "\n"
        "              yyy\n"
        "             yy yy\n"
        "            y y y y\n"
        "            yyyyyyy\n";

    Frame f(castle_image, castle_mask, 0x686868/* XXX: why grey? */ );

    Sprite* castle = new Sprite(screen,
        screen->width() - 32, screen->height() - 13, 22);
    castle->addFrame(f);
    screen->addSprite(castle);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Adds the environment (sea, etc.) to the screen.

Definition at line 148 of file aasaver.cpp.

{
    QString water_line_segment[] = {
        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
        "^^^^ ^^^  ^^^   ^^^    ^^^^      ",
        "^^^^      ^^^^     ^^^    ^^     ",
        "^^      ^^^^      ^^^    ^^^^^^  "
    };

    // tile the segments so they stretch across the screen
    int segment_size   = water_line_segment[0].length();
    int segment_repeat = int(screen->width()/segment_size) + 1;

    for (unsigned i = 0; i < ARRAY_SIZE(water_line_segment); ++i) {
        //do the tiling
        QString out;
        for (int r = 0; r < segment_repeat; ++r)
            out += water_line_segment[i];

        //create a sprite.
        Sprite* s = new Sprite(screen, 0, i + 5, 22);
        s->addFrame(Frame(out, QString(), 0x149494));
        screen->addSprite(s);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addFish ( Screen screen)

Adds a new fish sprite to screen.

Parameters:
screenThe Screen to add a fish to.

Definition at line 738 of file aasaver.cpp.

{
    screen->addSprite(newFish(screen));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addNessie ( Screen screen)

Adds a Nessie, the Loch Ness Monster sprite to screen.

Parameters:
screenThe Screen to add Nessie to.

Definition at line 1151 of file aasaver.cpp.

{
    QString nessie_image[] = {
"                                                          ____\n"
"            __{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}/   o  \\\n"
"          /    \\{}{}{}{}_{}{}{}{}{}{}{}{}{}{}?_{}{}{}?/     ____ >\n"
"  _{}{}{}|  __  |{}{}?/   \\{}{}{}{}_{}{}{}{}/   \\{}{}|     |\n"
" | \\{}{}?|  ||  |{}{}|     |{}{}?/   \\{}{}?|     |{}?|     |",

"                                                          ____\n"
"                                             __{}{}{}{}?/   o  \\\n"
"             _{}{}{}{}{}{}{}{}{}{}?_{}{}{}?/    \\{}{}?/     ____ >\n"
"   _{}{}{}?/   \\{}{}{}{}_{}{}{}{}/   \\{}{}|  __  |{}?|     |\n"
"  | \\{}{}?|     |{}{}?/   \\{}{}?|     |{}?|  ||  |{}?|     |\n",

"                                                          ____\n"
"                                  __{}{}{}{}{}{}{}{}{}{}/   o  \\\n"
" _{}{}{}{}{}{}{}{}{}{}{}_{}{}{}?/    \\{}{}{}{}_{}{}{}?/     ____ >\n"
"| \\{}{}{}{}{}_{}{}{}{}/   \\{}{}|  __  |{}{}?/   \\{}{}|     |\n"
" \\ \\{}{}{}?/   \\{}{}?|     |{}?|  ||  |{}{}|     |{}?|     |",

"                                                          ____\n"
"                       __{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}?/   o  \\\n"
"  _{}{}{}{}{}_{}{}{}?/    \\{}{}{}{}_{}{}{}{}{}{}{}{}{}/     ____ >\n"
" | \\{}{}{}?/   \\{}{}|  __  |{}{}?/   \\{}{}{}{}_{}{}{}|     |\n"
"  \\ \\{}{}?|     |{}?|  ||  |{}{}|     |{}{}?/   \\{}{}|     |",

"    ____\n"
"  /  o   \\{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}__\n"
"< ____     \\{}{}{}?_{}{}{}{}{}{}{}{}{}{}?_{}{}{}{}/    \\\n"
"      |     |{}{}/   \\{}{}{}{}_{}{}{}{}/   \\{}{}?|  __  |{}{}{}_\n"
"      |     |{}?|     |{}{}?/   \\{}{}?|     |{}{}|  ||  |{}{}?/ |",

"    ____\n"
"  /  o   \\{}{}{}{}?__\n"
"< ____     \\{}{}?/    \\{}{}{}?_{}{}{}{}{}{}{}{}{}{}?_\n"
"      |     |{}?|  __  |{}{}/   \\{}{}{}{}_{}{}{}{}/   \\{}{}{}?_\n"
"      |     |{}?|  ||  |{}?|     |{}{}?/   \\{}{}?|     |{}{}?/ |",

"    ____\n"
"  /  o   \\{}{}{}{}{}{}{}{}{}{}__\n"
"< ____     \\{}{}{}?_{}{}{}{}/    \\{}{}{}?_{}{}{}{}{}{}{}{}{}{}{}_\n"
"      |     |{}{}/   \\{}{}?|  __  |{}{}/   \\{}{}{}{}_{}{}{}{}{}/ |\n"
"      |     |{}?|     |{}{}|  ||  |{}?|     |{}{}?/   \\{}{}{}?/ /",

"    ____\n"
"  /  o   \\{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}?__\n"
"< ____     \\{}{}{}{}{}{}{}{}{}_{}{}{}{}/    \\{}{}{}?_{}{}{}{}{}_\n"
"      |     |{}{}{}_{}{}{}{}/   \\{}{}?|  __  |{}{}/   \\{}{}{}?/ |\n"
"      |     |{}{}/   \\{}{}?|     |{}{}|  ||  |{}?|     |{}{}?/ /"
    };

    QString nessie_mask[] = {
"\n"
"                                                            W\n"
"\n"
"\n"
"\n"
"",

"\n"
"     W\n"
"\n"
"\n"
"\n"
""
    };

    int nessie_num = m_randomSequence.getLong(2); // 0 = right, 1 = left.
    int x = -64, dir = 1;

    if(nessie_num == 1) {
        x = screen->width() - 2;
        dir = -1;
    }

    RandomMovingSprite *nessie = new RandomMovingSprite(screen, dir, 1.4, x, 2, 2);
    nessie->setFrameDelay(75);
    nessie->setFrameTime(400);

    for(unsigned i = 0; i < 4; ++i)
        nessie->addFrame(Frame(nessie_image[nessie_num * 4 + i], nessie_mask[nessie_num], 0x18B218));

    screen->addSprite(nessie);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addRandom ( Screen screen)

Adds a random object from the set (Shark, Big Fish, Nessie, Whale, Ship) to the sea.

Parameters:
screenThe Screen to add to.

Definition at line 1237 of file aasaver.cpp.

{
    int choice = m_randomSequence.getLong(5);

    switch(choice)
    {
        case 0:
            addShark(screen);
            break;
        case 1:
            addShip(screen);
            break;
        case 2:
            addBigFish(screen);
            break;
        case 3:
            addNessie(screen);
            break;
        case 4:
            addWhale(screen);
            break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addSeaweed ( Screen screen)

Adds a seaweed to a random position of the sea bottom.

Parameters:
screenThe Screen to add into.

Definition at line 243 of file aasaver.cpp.

{
    QString seaweed_image[] = {"", ""};
    int height = m_randomSequence.getLong(5) + 3;
    for (int i = 1; i <= height; ++i)
    {
        int left_side  = i % 2;
        int right_side = !left_side;
        seaweed_image[left_side]  += "(\n";
        seaweed_image[right_side] += " )\n";
    }

    int x = m_randomSequence.getLong(screen->width() - 2) + 1;
    int y = screen->height() - height;

    // Keep guessing random numbers until the seaweed isn't too
    // bunched up.
    while(Seaweed::isTooClose(x))
        x = m_randomSequence.getLong(screen->width() - 2) + 1;

    Seaweed* s = new Seaweed(screen, x, y,
        m_randomSequence.getLong(4*60000) + (8*60000)); // seaweed lives for 8 to 12 minutes
    s->addFrame(Frame(seaweed_image[0], QString(), 0x18AF18));
    s->addFrame(Frame(seaweed_image[1], QString(), 0x18AF18));
    s->setFrameDelay(m_randomSequence.getLong(50) + 250);
    screen->addSprite(s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addShark ( Screen screen)

Adds a shark sprite to screen.

The shark can kill() fish it comes in contact with (they will spawn more fish automatically).

Parameters:
screenThe Screen to add the shark to.

Definition at line 844 of file aasaver.cpp.

{
    QString shark_image[] = {
"                              __\n"
"                             ( `\\\n"
"  ,{}{}{}{}{}{}{}{}{}{}{}{}{}" ")   `\\\n" // trigraphs suck
";' `.{}{}{}{}{}{}{}{}{}{}{}{}" "(     `\\__\n" // trigraphs suck
" ;   `.{}{}{}{}{}{}?__..---''          `~~~~-._\n"
"  `.   `.____...--''                       (b  `--._\n"
"    >                     _.-'      .((      ._     )\n"
"  .`.-`--...__         .-'     -.___.....-(|/|/|/|/'\n"
" ;.'{}{}{}{}?`. ...----`.___.',,,_______......---'\n"
" '{}{}{}{}{}?" "'-'\n", // trigraphs suck

"                                                     \n"
"                                                     \n"
"                                                     \n"
"                                                     \n"
"                                                     \n"
"                                           cR        \n"
"                                                     \n"
"                                          cWWWWWWWW  \n"
"                                                     \n"
"                                                     \n",

"                     __\n"
"                    /' )\n"
"                  /'   ({}{}{}{}{}{}{}{}{}{}{}{}{},\n"
"              __/'     ){}{}{}{}{}{}{}{}{}{}{}{}.' `;\n"
"      _.-~~~~'          ``---..__{}{}{}{}{}{}?.'   ;\n"
" _.--'  b)                       ``--...____.'   .'\n"
"(     _.      )).      `-._                     <\n"
" `\\|\\|\\|\\|)-.....___.-     `-.         __...--'-.'.\n"
"   `---......_______,,,`.___.'----... .'{}{}{}{}?`.;\n"
"                                     `-`{}{}{}{}{}?`\n",

"                                                     \n"
"                                                     \n"
"                                                     \n"
"                                                     \n"
"                                                     \n"
"        Rc                                           \n"
"                                                     \n"
"  WWWWWWWWc                                          \n"
"                                                     \n"
"                                                     \n"
    };

    int shark_num   = m_randomSequence.getLong(ARRAY_SIZE(shark_image)/2);
    int shark_index = shark_num * 2;
    QString color_mask = randColor(shark_image[shark_index+1]);
    Frame sharkFrame(shark_image[shark_index], color_mask, 0x18B2B2);

    int x = -53;
    int y = 9 + m_randomSequence.getLong(screen->height() - (10 + 9));
    int dir = (shark_num % 2) ? -1 : 1;

    if(dir < 0)
        x = screen->width() - 2;

    RandomMovingSprite* shark = new RandomMovingSprite(screen, dir, 2, x, y, 2 /* Always at 2 */);
    shark->addFrame(sharkFrame);
    screen->addSprite(shark);

    TeethSprite *teeth = new TeethSprite(shark);
    screen->addSprite(teeth);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addShip ( Screen screen)

Adds a ship sprite to screen.

Parameters:
screenThe Screen to add the ship to.

Definition at line 917 of file aasaver.cpp.

{
    QString ship_image[] = {
"     |    |    |\n"
"    )_)  )_)  )_)\n"
"   )___))___))___)\\\n"
"  )____)____)_____)\\\\\n"
"_____|____|____|____\\\\\\__\n"
"\\                   /",

"     y    y    y\n"
"                 \n"
"                  w\n"
"                   ww\n"
"yyyyyyyyyyyyyyyyyyyywwwyy\n"
"y                   y",

"         |    |    |\n"
"        (_(  (_(  (_(\n"
"      /(___((___((___(\n"
"    //(_____(____(____(\n"
"__///____|____|____|_____\n"
"    \\                   /",

"         y    y    y\n"
"                 \n"
"      w            \n"
"    ww               \n"
"yywwwyyyyyyyyyyyyyyyyyyyy\n"
"    y                   y"
    };

    int ship_num = m_randomSequence.getLong(17) % 2; // right == 0, left == 1
    int x = -24, dir = 1;

    if(ship_num == 1) {
        x = screen->width() - 2;
        dir = -1;
    }

    RandomMovingSprite *ship = new RandomMovingSprite(screen, dir, 1.0, x, 0, 2);
    ship->addFrame(Frame(ship_image[2 * ship_num], ship_image[2 * ship_num + 1], 0xFFFFFF));
    screen->addSprite(ship);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::addWhale ( Screen screen)

Adds a whale sprite to screen.

Parameters:
screenThe Screen to add the whale to.

Definition at line 962 of file aasaver.cpp.

{
    QString whale_image[] = {
"        .-----:\n"
"      .'       `.\n"
",{}{}/       (o) \\\n"
"\\`._/          ,__)",

"             C C\n"
"           CCCCCCC\n"
"           C  C  C\n"
"        BBBBBBB\n"
"      BB       BB\n"
"B    B       BWB B\n"
"BBBBB          BBBB",

"    :-----.\n"
"  .'       `.\n"
" / (o)       \\{}{},\n"
"(__,          \\_.'/",

"   C C\n"
" CCCCCCC\n"
" C  C  C\n"
"    BBBBBBB\n"
"  BB       BB\n"
" B BWB       B    B\n"
"BBBB          BBBBB"
    };

    QString spouty[] = {
"\n"
"\n"
"   :",

"\n"
"   :\n"
"   :",

"  . .\n"
"  -:-\n"
"   :",

"  . .\n"
" .-:-.\n"
"   :",

"  . .\n"
"'.-:-.`\n"
"'  :  '",

"\n"
" .- -.\n"
";  :  ;",

"\n"
"\n"
";     ;"
    };

    int whale_num = m_randomSequence.getLong(2); // 0 = right, 1 = left
    int x = -18, spout_align = 11, dir = 1;

    if (whale_num == 1)
    {
        x = screen->width() - 2;
        spout_align = 1; // Waterspout closer to left side now.
        dir = -1;
    }

    QString mask = whale_image[2 * whale_num + 1];

    RandomMovingSprite *whale = new RandomMovingSprite(screen, dir, 1.0, x, 0, 2);
    whale->setFrameDelay(80);
    whale->setFrameTime(40);

    // We have to add some frames now.  The first five will have no water spout.
    QString blankWhaleFrame = QString("\n\n\n") + whale_image[2 * whale_num];

    for(unsigned i = 0; i < 5; ++i)
        whale->addFrame(Frame(blankWhaleFrame, mask, 0xFFFFFF));

    // Now add frames for the animated water spout.
    QString whaleFrame = whale_image[2 * whale_num];
    for (unsigned i = 0; i < ARRAY_SIZE(spouty); ++i)
    {
        QStringList spoutLines = spouty[i].split('\n');
        QString spout;
        QString padding;

        padding.fill(' ', spout_align);

        // Move spout over an appropriate distance to line up right.
        foreach(const QString &spoutLine, spoutLines) {
            spout += padding;
            spout += spoutLine;
            spout += '\n';
        }

        // Add spout to whale frame.
        whale->addFrame(Frame(spout + whaleFrame, mask, 0xFFFFFF));
    }

    screen->addSprite(whale);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double AASaver::doubleRand ( int  max)

Definition at line 102 of file aasaver.cpp.

{
    return m_randomSequence.getDouble() * max;
}

Here is the caller graph for this function:

AASaver * AASaver::instance ( ) [static]

Definition at line 83 of file aasaver.cpp.

{
    if(!m_instance)
        std::abort();

    return m_instance;
}

Here is the caller graph for this function:

Sprite * AASaver::newFish ( Screen screen)

Returns a new fish sprite, which has not yet been added to a screen.

Parameters:
screenThe Screen to use when constructing the Sprite.
Todo:
Combine with addFish().

Definition at line 515 of file aasaver.cpp.

{
    QString fish_image[] = {
"       \\\n"
"     ...\\..,\n"
"\\" "{}" "/'       \\\n" // trigraphs suck
" >=     (  ' >\n"
"/{}\\      / /\n"
"    `\"'\"'/''\n",

"       2\n"
"     1112111\n"
"6  11       1\n"
" 66     7  4 5\n"
"6  1      3 1\n"
"    11111311\n",

"      /\n"
"  ,../...\n"
" /       '\\" "{}" "/\n" // trigraphs suck
"< '  )     =<\n"
" \\ \\      /{}\\\n"
"  `'\\'\"'\"'\n",

"      2\n"
"  1112111\n"
" 1       11  6\n"
"5 4  7     66\n"
" 1 3      1  6\n"
"  11311111\n",
"    \\\n"
"\\?/--\\\n"
">=  (o>\n"
"/?\\__/\n"
"    /\n",

"    2\n"
"6 1111\n"
"66  745\n"
"6 1111\n"
"    3\n",

"  /\n"
" /--\\?/\n"
"<o)  =<\n"
" \\__/?\\\n"
"  \\\n",

"  2\n"
" 1111 6\n"
"547  66\n"
" 1111 6\n"
"  3\n",

"       \\:.\n"
"\\;,{}?,;\\\\\\\\\\,,\n"
"  \\\\\\\\\\;;:::::o\n"
"  ///;;::::::::<\n"
" /;`?``/////``\n",

"       222\n"
"666   1122211\n"
"  6661111111114\n"
"  66611111111115\n"
" 666 113333311\n",

"      .:/\n"
"   ,,///;,{}?,;/\n"
" o:::::::;;///\n"
">::::::::;;\\\\\\\n"
"  ''\\\\\\\\\\''?';\\\n",

"      222\n"
"   1122211   666\n"
" 4111111111666\n"
"51111111111666\n"
"  113333311 666\n",

"  __\n"
"><_'>\n"
"   '\n",

"  11\n"
"61145\n"
"   3\n",

" __\n"
"<'_><\n"
" `\n",

" 11\n"
"54116\n"
" 3\n",

"   ..\\,\n"
">='   ('>\n"
"  '''/''\n",

"   1121\n"
"661   745\n"
"  111311\n",

"  ,/..\n"
"<')   `=<\n"
" ``\\```\n",

"  1211\n"
"547   166\n"
" 113111\n",

"   \\\n"
"  / \\\n"
">=_('>\n"
"  \\_/\n"
"   /\n",

"   2\n"
"  1 1\n"
"661745\n"
"  111\n"
"   3\n",

"  /\n"
" / \\\n"
"<')_=<\n"
" \\_/\n"
"  \\\n",

"  2\n"
" 1 1\n"
"547166\n"
" 111\n"
"  3\n",

"  ,\\\n"
">=('>\n"
"  '/\n",

"  12\n"
"66745\n"
"  13\n",

" /,\n"
"<')=<\n"
" \\`\n",

" 21\n"
"54766\n"
" 31\n",

"  __\n"
"\\/ o\\\n"
"/\\__/\n",

"  11\n"
"61 41\n"
"61111\n",

" __\n"
"/o \\/\n"
"\\__/\\\n",

" 11\n"
"14 16\n"
"11116\n"
};

    // # 1: body
    // # 2: dorsal fin
    // # 3: flippers
    // # 4: eye
    // # 5: mouth
    // # 6: tailfin
    // # 7: gills*
    int fish_num   = m_randomSequence.getLong(ARRAY_SIZE(fish_image)/2);
    int fish_index = fish_num * 2;

    double speed = doubleRand(2) + 0.25;
    int depth = 3 + m_randomSequence.getLong(18);

    QString color_mask = fish_image[fish_index+1];
    color_mask.replace('4', 'W');

    color_mask = randColor(color_mask);

    Frame fishFrame(fish_image[fish_index], color_mask, 0);
    int max_height = 9;
    int min_height = screen->height() - fishFrame.height();

    int x, y, dir;
    y = max_height + m_randomSequence.getLong(min_height - max_height);
    if (fish_num % 2)
    {
        x   = screen->width() - 2;
        dir = -1;
    }
    else
    {
        x   = 1 - fishFrame.width();
        dir = 1;
    }

    Sprite* fish = new FishSprite(screen, dir, speed, x, y, depth);
    fish->addFrame(fishFrame);

    return fish;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AASaver::paintEvent ( QPaintEvent *  pe) [virtual]

Reimplemented to update the widget when it gets dirty.

Definition at line 1261 of file aasaver.cpp.

{
    // Dirty region is passed instead of the entire viewport for efficiency.
    screen->paint(pe);
}

Here is the call graph for this function:

QString AASaver::randColor ( QString  color_mask)

Returns a QString holding a color mask, created by choosing random colors to replace numbers in color_mask.

Definition at line 91 of file aasaver.cpp.

{
    char colors[] = {'c','C','r','R','y','Y','b','B','g','G','m','M'};
    for (int i = 1; i <= 9; ++i)
    {
        char color = colors[m_randomSequence.getLong(ARRAY_SIZE(colors))];
        color_mask.replace('0' + i, color);
    }
    return color_mask;
}

Here is the caller graph for this function:


Member Data Documentation

AASaver * AASaver::m_instance = 0 [static, private]

Static singleton instance.

Definition at line 81 of file aasaver.h.

KRandomSequence AASaver::m_randomSequence [private]

Randomizes the sequence of fish, seaweeds, colors, etc.

Definition at line 78 of file aasaver.h.

Screen* AASaver::screen [private]

Handles the animation and drawing.

Definition at line 75 of file aasaver.h.


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