Commit 6f28ed23 authored by Waldo Bastian's avatar Waldo Bastian
Browse files

WABA: Use KRandomSequence

svn path=/trunk/kdegames/kmines/; revision=36406
parent 8d7463ec
......@@ -18,12 +18,3 @@ const Level LEVELS[3] = {
{30, 16, 99} // Expert
};
void initRandomWithTime()
{
srandom(time(0));
}
int randomInt(int min, int max)
{
return min + (int)( (max-min+1.0)*random() / (RANDOM_MAX+1.0) );
}
......@@ -3,9 +3,6 @@
#include <qglobal.h>
void initRandomWithTime();
int randomInt(int min, int max);
/* Strings for the configuration file */
extern const char *OP_GRP;
extern const char *OP_UMARK;
......
......@@ -14,7 +14,7 @@ Field::Field(QWidget *parent, const char *name)
setLineWidth(2);
setMidLineWidth(2);
initRandomWithTime();
random.setSeed(0);
QPainter p;
pm_flag.resize(16, 16);
......@@ -304,8 +304,8 @@ void Field::mouseReleaseEvent( QMouseEvent *e )
for(uint k=0; k<lev.nbMines; k++) {
uint i, j;
do {
i = randomInt(0, lev.width-1);
j = randomInt(0, lev.height-1);
i = random.getLong(lev.width);
j = random.getLong(lev.height);
}
while ( (pfield(i+1, j+1) & MINE)
|| ((i+1)==ic && (j+1)==jc) );
......
#ifndef FIELD_H
#define FIELD_H
#include <krandomsequence.h>
#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
......@@ -50,6 +52,8 @@ class Field : public QFrame
private:
QArray<uint> _pfield;
Level lev;
KRandomSequence random;
bool _stop; /* end of game ? */
bool noGame, isPaused;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment