Changeset 260


Ignore:
Timestamp:
Jan 22, 2011, 6:02:36 PM (10 years ago)
Author:
sam
Message:

Quick initial random board.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r259 r260  
    1616#include <cmath>
    1717#include <cstdlib>
     18#include <ctime>
    1819
    1920#include "core.h"
     
    6566    data->click = Sampler::Register(WAV_CLICK);
    6667
    67     for (int j = 0; j < 8; j++)
    68         for (int i = 0; i < 8; i++)
    69         {
    70             int id = (35 + i + (i ^ (j + 13)) * (2 * j + 711)) % 9;
     68    srand(rand() ^ time(NULL));
     69
     70restart:
     71    for (int j = 0; j < 8; j++)
     72        for (int i = 0; i < 8; i++)
     73        {
     74            int id = rand() % 7;
    7175            data->pieces[i][j] = new Piece(game, Int2(i, j), 25 + 5 * id);
    7276            Ticker::Ref(data->pieces[i][j]);
    7377        }
     78
     79    int list[8][8];
     80    if (ListMashes(list))
     81    {
     82        for (int j = 0; j < 8; j++)
     83            for (int i = 0; i < 8; i++)
     84                Ticker::Unref(data->pieces[i][j]);
     85        goto restart;
     86    }
    7487
    7588    data->nextblink = 0.0f;
     
    213226                list[i][j2 - 1] = list[i][j2];
    214227            }
    215             data->pieces[i][7] = new Piece(data->game, Int2(i, 7), 25 + 5 * (rand() % 8));
     228            data->pieces[i][7] = new Piece(data->game, Int2(i, 7), 25 + 5 * (rand() % 7));
    216229            Ticker::Ref(data->pieces[i][7]);
    217230            list[i][7] = 0;
Note: See TracChangeset for help on using the changeset viewer.