Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
KMines
Commits
6f28ed23
Commit
6f28ed23
authored
Dec 13, 1999
by
Waldo Bastian
Browse files
WABA: Use KRandomSequence
svn path=/trunk/kdegames/kmines/; revision=36406
parent
8d7463ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
defines.cpp
View file @
6f28ed23
...
...
@@ -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
)
);
}
defines.h
View file @
6f28ed23
...
...
@@ -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
;
...
...
field.cpp
View file @
6f28ed23
...
...
@@ -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
=
random
Int
(
0
,
lev
.
width
-
1
);
j
=
random
Int
(
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
)
);
...
...
field.h
View file @
6f28ed23
#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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment