Changeset 275


Ignore:
Timestamp:
Jan 24, 2011, 2:45:47 AM (10 years ago)
Author:
sam
Message:

Minor comments and code reorg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r274 r275  
    7474        for (int i = 0; i < 8; i++)
    7575        {
    76             int id = rand() % 7;
    77             data->pieces[i][j] = new Piece(game, Int2(i, j), 25 + 5 * id);
     76            int id = 25 + 5 * (rand() % 7);
     77            data->pieces[i][j] = new Piece(game, Int2(i, j), id);
    7878            if (j)
    7979                data->pieces[i][j]->SetBelow(data->pieces[i][j - 1]);
     
    150150        break;
    151151    case BoardData::GRAB:
    152         /* Should we stop dragging? */
    153152        if (mouse.x >= 0 && mouse.y >= 0)
    154153        {
     154            /* Mouse is still in the window, keep grabbing */
    155155            data->grabbed->Grab(mouse - data->mouse);
    156156            Int2 cur_pos = data->grabbed->GetPos();
     
    178178                  - data->grabbed->GetPos()).sqlen() > 100 * 100)
    179179        {
     180            /* Mouse released, or exited window, or dragged too far. */
    180181            data->grabbed->Ungrab();
    181182            if (data->dst_cell != Int2(-1))
     
    235236    b->Goto(cell_a * 48, 0.3f);
    236237
    237     /* Remove matching pieces */
     238    /* Remove matching pieces and store them in Mash objects */
    238239    do
    239240    {
     
    251252            Piece *below = data->pieces[i][7];
    252253
     254            /* Change coordinates for the whole colume above */
    253255            for (int j2 = j + 1; j2 < 8; j2++)
    254256            {
     
    258260                list[i][j2 - 1] = list[i][j2];
    259261            }
     262
     263            /* Spawn a new piece above all the others and attach it to
     264             * the board. */
    260265            Int2 newpos = Int2(i * 48, below->GetPos().y + 48);
    261             data->pieces[i][7] = new Piece(data->game, Int2(i, 7), 25 + 5 * (rand() % 7));
     266            int id = 25 + 5 * (rand() % 7);
     267            data->pieces[i][7] = new Piece(data->game, Int2(i, 7), id);
    262268            data->pieces[i][7]->SetBelow(below);
    263269            data->pieces[i][7]->SetPos(newpos);
Note: See TracChangeset for help on using the changeset viewer.