Changeset 279


Ignore:
Timestamp:
Jan 24, 2011, 1:52:54 PM (10 years ago)
Author:
sam
Message:

Play a few additional sounds (whip and pop).

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r277 r279  
    3535    Game *game;
    3636    int screen, board, tiles;
    37     int click;
     37    int click, whip;
    3838    Piece *pieces[8][8];
    3939    Piece *grabbed;
     
    4343    Int2 mouse;
    4444    Int3 buttons;
    45     float nextblink;
     45    float nextblink, whipdelay;
    4646
    4747    enum
     
    6767    data->tiles = Tiler::Register(PNG_TILES, 48, 48, 1.0f);
    6868    data->click = Sampler::Register(WAV_CLICK);
     69    data->whip = Sampler::Register(WAV_WHIP);
    6970
    7071    srand(rand() ^ time(NULL));
     
    7475        for (int i = 0; i < 8; i++)
    7576        {
    76             int id = 25 + 5 * (rand() % 8);
     77            int id = 25 + 5 * (rand() % 7);
    7778            data->pieces[i][j] = new Piece(game, Int2(i, j), id);
    7879            if (j)
     
    9596    data->mashes = NULL;
    9697    data->nextblink = 0.0f;
     98    data->whipdelay = 0.0f;
    9799    data->state = BoardData::IDLE;
    98100}
     
    111113        data->nextblink = (float)(200 + rand() % 500);
    112114    }
     115
     116    /* Do not whip too often, the sound may become annoying */
     117    data->whipdelay -= deltams;
    113118
    114119    /* Get rid of finished mashes */
     
    164169            if (cur_cell != data->dst_cell)
    165170            {
     171                if (data->whipdelay < 0.0f)
     172                {
     173                    Sampler::PlaySample(data->whip);
     174                    data->whipdelay = 300.0f;
     175                }
    166176                if (data->dst_cell != Int2(-1))
    167177                    data->pieces[data->dst_cell.i]
     
    295305             * the board. */
    296306            Int2 newpos = Int2(i * 48, below->GetPos().y + 48);
    297             int id = 25 + 5 * (rand() % 8);
     307            int id = 25 + 5 * (rand() % 7);
    298308            data->pieces[i][7] = new Piece(data->game, Int2(i, 7), id);
    299309            data->pieces[i][7]->SetBelow(below);
     
    359369    Tiler::Deregister(data->tiles);
    360370    Sampler::Deregister(data->click);
     371    Sampler::Deregister(data->whip);
    361372    delete data;
    362373}
  • trunk/monsterz/mash.cpp

    r278 r279  
    3131private:
    3232    Game *game;
     33    int duh, pop;
    3334    Piece *pieces[8 * 8];
    3435    Int2 cells[8 * 8];
     
    5455    data->game = game;
    5556    Ticker::Ref(game);
     57    data->duh = Sampler::Register(WAV_DUH);
     58    data->pop = Sampler::Register(WAV_POP);
    5659    data->npieces = 0;
    5760    data->state = MashData::WAIT;
     
    9194        if (allready)
    9295        {
     96            Sampler::PlaySample(data->pop);
    9397            for (int n = 0; n < data->npieces; n++)
    9498                data->pieces[n]->Pop();
     
    137141    for (int n = 0; n < data->npieces; n++)
    138142        Ticker::Unref(data->pieces[n]);
     143    Sampler::Deregister(data->duh);
     144    Sampler::Deregister(data->pop);
    139145    Ticker::Unref(data->game);
    140146    delete data;
  • trunk/monsterz/monsterz.h

    r253 r279  
    1414
    1515static char const * const WAV_CLICK = "monsterz/click.wav";
    16 
     16static char const * const WAV_DUH = "monsterz/duh.wav";
     17static char const * const WAV_POP = "monsterz/pop.wav";
     18static char const * const WAV_WHIP = "monsterz/whip.wav";
  • trunk/win32/monsterz.vcxproj

    r257 r279  
    1515    <ClInclude Include="..\monsterz\game.h" />
    1616    <ClInclude Include="..\monsterz\mash.h" />
     17    <ClInclude Include="..\monsterz\monsterz.h" />
    1718    <ClInclude Include="..\monsterz\piece.h" />
    1819    <ClInclude Include="..\src\audio.h" />
Note: See TracChangeset for help on using the changeset viewer.