diff options
Diffstat (limited to 'examples/declarative/demos/minehunt/minehunt.cpp')
-rw-r--r-- | examples/declarative/demos/minehunt/minehunt.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/declarative/demos/minehunt/minehunt.cpp b/examples/declarative/demos/minehunt/minehunt.cpp index 2ef4a9be..d9237eee 100644 --- a/examples/declarative/demos/minehunt/minehunt.cpp +++ b/examples/declarative/demos/minehunt/minehunt.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include <stdlib.h> -#include <QRandomGenerator> +#include <QTime> #include <QTimer> #include "minehunt.h" @@ -63,6 +63,7 @@ MinehuntGame::MinehuntGame() : numCols(9), numRows(9), playing(true), won(false) { setObjectName("mainObject"); + srand(QTime(0,0,0).secsTo(QTime::currentTime())); //initialize array for(int ii = 0; ii < numRows * numCols; ++ii) { @@ -82,8 +83,8 @@ void MinehuntGame::setBoard() int mines = nMines; remaining = numRows*numCols-mines; while ( mines ) { - int col = QRandomGenerator::bounded(numCols); - int row = QRandomGenerator::bounded(numRows); + int col = int((double(rand()) / double(RAND_MAX)) * numCols); + int row = int((double(rand()) / double(RAND_MAX)) * numRows); TileData* t = tile( row, col ); |