Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Games
Bomber
Commits
6822ab7a
Commit
6822ab7a
authored
Jul 31, 2020
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port KRandom::random
parent
6517c641
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
8 deletions
+6
-8
src/board.cpp
src/board.cpp
+2
-3
src/building.cpp
src/building.cpp
+3
-4
src/explodable.cpp
src/explodable.cpp
+1
-1
No files found.
src/board.cpp
View file @
6822ab7a
...
...
@@ -24,9 +24,8 @@
#include <QGraphicsView>
#include <QStandardPaths>
#include <QTimer>
#include <QRandomGenerator>
// KDE
#include <KRandom>
// Bomber
#include "bomb.h"
...
...
@@ -143,7 +142,7 @@ void BomberBoard::newLevel(unsigned int level)
if
(
max
<
5
)
{
max
=
5
;
}
unsigned
int
height
=
(
K
Random
::
random
()
%
(
max
-
min
)
)
+
min
;
unsigned
int
height
=
Q
Random
Generator
::
global
()
->
bounded
(
max
-
min
)
+
min
;
m_buildingBlocks
+=
height
;
auto
building
=
new
Building
(
m_renderer
,
this
,
i
+
1
,
height
);
...
...
src/building.cpp
View file @
6822ab7a
...
...
@@ -21,8 +21,7 @@
// KDE
#include <KGameRenderedItem>
#include <KRandom>
#include <QRandomGenerator>
// Bomber
#include "board.h"
...
...
@@ -87,11 +86,11 @@ void Building::setupBuildingTiles()
++
styleCount
;
}
}
unsigned
int
style
=
K
Random
::
random
()
%
styleCount
;
unsigned
int
style
=
Q
Random
Generator
::
global
()
->
bounded
(
styleCount
)
;
unsigned
int
maxVarient
=
m_renderer
->
frameCount
(
QStringLiteral
(
"building_%1"
).
arg
(
style
));
for
(
unsigned
int
heightIndex
=
0
;
heightIndex
<
m_height
-
1
;
++
heightIndex
)
{
unsigned
int
varient
=
K
Random
::
random
()
%
(
maxVarient
);
unsigned
int
varient
=
Q
Random
Generator
::
global
()
->
bounded
(
maxVarient
);
const
QString
pixmap
=
QStringLiteral
(
"building_%1_%2"
).
arg
(
style
).
arg
(
varient
);
m_buildingTiles
.
append
(
createBuildingTile
(
pixmap
));
}
...
...
src/explodable.cpp
View file @
6822ab7a
...
...
@@ -91,7 +91,7 @@ void Explodable::setVelocity(qreal vX)
void
Explodable
::
setRandomFrame
()
{
setFrame
(
K
Random
::
random
());
setFrame
(
Q
Random
Generator
::
global
()
->
generate
());
}
/**
...
...
Write
Preview
Markdown
is supported
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