Changeset 311


Ignore:
Timestamp:
Jan 30, 2011, 6:31:14 PM (8 years ago)
Author:
sam
Message:

Add idle animations.

Location:
trunk/monsterz
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r308 r311  
    218218        for (int j = 0; j < 8; j++)
    219219            for (int i = 0; i < 8; i++)
    220                 data->pairs[i][j].id = 1 + rand() % 8;
     220                data->pairs[i][j].id = 1 + rand() % 9;
    221221    } while (ListMashes(list) || !(data->nmoves = ListMoves(list)));
    222222
     
    312312            {
    313313                Piece *old = data->pairs[i][j].piece;
    314                 int id = 1 + rand() % 8;
     314                int id = 1 + rand() % 9;
    315315                data->pairs[i][j].id = id;
    316316                data->pairs[i][j].piece = new Piece(data->emitter, int2(i, j), 80 + 20 * id);
     
    337337                 * the board. */
    338338                int2 newpos = int2(i * 48, below->GetPos().y + 48);
    339                 int id = 1 + rand() % 8;
     339                int id = 1 + rand() % 9;
    340340                data->pairs[i][7].id = id;
    341341                data->pairs[i][7].piece = new Piece(data->emitter, int2(i, 7), 80 + 20 * id);
  • trunk/monsterz/monsterz.h

    r305 r311  
    1818static char const * const WAV_WHIP = "monsterz/sound/whip.wav";
    1919
     20/* Duration of the idle loop */
     21static int const DELAY_IDLE = 300;
    2022/* Duration of a blink */
    21 static int const DELAY_BLINK = 400;
     23static int const DELAY_BLINK = 200;
    2224/* Wait time until the next whip sound is allowed */
    2325static int const DELAY_WHIP = 300;
  • trunk/monsterz/piece.cpp

    r303 r311  
    6565    data->id = id;
    6666    data->state = PieceData::IDLE;
     67    data->timer = RandF(DELAY_IDLE);
    6768}
    6869
     
    237238    {
    238239    case PieceData::IDLE:
    239         break;
    240     case PieceData::BLINK:
    241240        data->timer -= deltams;
    242241        if (data->timer < 0.0f)
     242            data->timer = DELAY_IDLE;
     243        break;
     244    case PieceData::BLINK:
     245        data->timer -= deltams;
     246        if (data->timer < 0.0f)
     247        {
    243248            data->state = PieceData::IDLE;
     249            data->timer = RandF(DELAY_IDLE);
     250        }
    244251        break;
    245252    case PieceData::GRAB:
     
    265272        }
    266273        if (data->timer > moving_time + 200.0f)
     274        {
    267275            data->state = PieceData::IDLE;
     276            data->timer = RandF(DELAY_IDLE);
     277        }
    268278        break;
    269279    }
     
    273283        {
    274284            float3 pos(data->pos.x + 24, data->pos.y + 177, 5);
    275             int start = data->id + 10;
    276             int stop = data->id + 13;
     285            int start = data->id + 12;
     286            int stop = data->id + 15;
    277287            for (int id = start; id < stop; id++)
    278288            {
    279                 float3 vel(RandF(-0.3f, 0.3f), RandF(0.2f, 0.3f), 0.0f);
     289                float angle = RandF(-1.2f, 1.2f);
     290                float speed = RandF(0.3f, 0.5f);
     291                float3 vel(speed * sinf(angle), speed * cosf(angle), 0.0f);
    280292                data->emitter->AddParticle(id, pos, vel);
    281293            }
     
    303315    {
    304316    case PieceData::IDLE:
    305         break;
    306     case PieceData::BLINK:
    307         id = data->id + 1;
    308         break;
    309     case PieceData::GRAB:
    310         id = data->id + 1;
     317    {
     318        int off = data->timer * 3 / DELAY_IDLE;
     319        if (off < 0) off = 0;
     320        if (off > 2) off = 2;
     321        id = data->id + off;
     322        break;
     323    }
     324    case PieceData::BLINK:
     325        id = data->id + 3;
     326        break;
     327    case PieceData::GRAB:
     328        id = data->id + 3;
    311329        z = 4;
    312330        break;
    313331    case PieceData::UNGRAB:
    314332        if ((data->cell * 48 - data->src).sqlen() > 24 * 24)
    315             id = data->id + 5;
     333            id = data->id + 7;
    316334        z = 4;
    317335        break;
     
    324342        if (off < 0) off = 0;
    325343        if (off > 4) off = 4;
    326         id = data->id + 5 + off;
     344        id = data->id + 7 + off;
    327345        break;
    328346    }
Note: See TracChangeset for help on using the changeset viewer.