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
KSpaceDuel
Commits
253938a2
Commit
253938a2
authored
Jul 13, 2020
by
Albert Astals Cid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
KRandomSequence -> QRandomGenerator
parent
3b43aefa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
14 deletions
+15
-14
CMakeLists.txt
CMakeLists.txt
+1
-1
ai.cpp
ai.cpp
+4
-3
ai.h
ai.h
+2
-2
mainview.cpp
mainview.cpp
+6
-6
mainview.h
mainview.h
+2
-2
No files found.
CMakeLists.txt
View file @
253938a2
project
(
kspaceduel
)
cmake_minimum_required
(
VERSION 3.5 FATAL_ERROR
)
set
(
QT_MIN_VERSION
"5.
9
.0"
)
set
(
QT_MIN_VERSION
"5.
10
.0"
)
set
(
KF5_MIN_VERSION
"5.46.0"
)
find_package
(
ECM
${
KF5_MIN_VERSION
}
REQUIRED CONFIG
)
...
...
ai.cpp
View file @
253938a2
...
...
@@ -33,6 +33,7 @@ int Ai::calcNextShot[Options::EnumAiDifficulty::COUNT] = {300,200,90,60};
Ai
::
Ai
(
int
pn
,
ShipSprite
*
s
[
2
],
QList
<
BulletSprite
*>*
b
[
2
],
QList
<
MineSprite
*>*
m
[
2
],
SConfig
*
c
)
:
random
(
QRandomGenerator
::
securelySeeded
())
{
int
i
;
...
...
@@ -89,8 +90,8 @@ void Ai::newRound()
calculateCollisions
=
(
int
)(
calcCollisions
[
Options
::
aiDifficulty
(
playerNumber
)]
/
cfg
->
gamespeed
);
waitShot
=
(
int
)
rint
(
random
.
getDouble
(
)
*
calcNextShot
[
Options
::
aiDifficulty
(
playerNumber
)]
waitShot
=
(
int
)
rint
(
random
.
bounded
(
1.0
)
*
calcNextShot
[
Options
::
aiDifficulty
(
playerNumber
)]
/
cfg
->
gamespeed
);
qDeleteAll
(
myShots
);
...
...
@@ -724,7 +725,7 @@ void Ai::chooseAction()
shoot
=
true
;
score
=
bestScore
;
calculateCollisions
=
0
;
waitShot
=
(
int
)
rint
(
random
.
getDouble
(
)
*
waitShot
=
(
int
)
rint
(
random
.
bounded
(
1.0
)
*
calcNextShot
[
Options
::
aiDifficulty
(
playerNumber
)]
/
cfg
->
gamespeed
);
}
...
...
ai.h
View file @
253938a2
...
...
@@ -18,7 +18,7 @@
#ifndef __KSD_AI_H
#define __KSD_AI_H
#include <
K
Random
Sequence
>
#include <
Q
Random
Generator
>
#include "dialogs.h"
#include "options.h"
...
...
@@ -76,7 +76,7 @@ private:
SConfig
*
cfg
;
K
Random
Sequence
random
;
Q
Random
Generator
random
;
//actions
Rotation
rotation
;
...
...
mainview.cpp
View file @
253938a2
...
...
@@ -63,7 +63,7 @@ MyMainView::MyMainView(QWidget *parent)
{
int
i
,
p
;
setMinimumSize
(
600
,
400
);
random
.
se
tSe
ed
(
0
);
random
.
seed
(
0
);
QPixmap
backgr
(
QStandardPaths
::
locate
(
QStandardPaths
::
DataLocation
,
QStringLiteral
(
MV_BACKGROUND
)));
field
.
setBackgroundBrush
(
QBrush
(
backgr
));
...
...
@@ -464,7 +464,7 @@ void MyMainView::newRound()
double
mx
,
my
;
int
i
;
timeToNextPowerup
=
random
.
getDouble
()
*
config
.
powerupRefreshTime
;
timeToNextPowerup
=
random
.
bounded
(
config
.
powerupRefreshTime
)
;
qDeleteAll
(
powerups
);
powerups
.
clear
();
...
...
@@ -841,15 +841,15 @@ void MyMainView::calculatePowerups()
if
(
timeToNextPowerup
<
0
)
{
int
type
,
x
,
y
;
timeToNextPowerup
=
random
.
getDouble
()
*
config
.
powerupRefreshTime
;
type
=
random
.
getLong
(
PowerupSprite
::
PowerupNum
);
timeToNextPowerup
=
random
.
bounded
(
config
.
powerupRefreshTime
)
;
type
=
random
.
bounded
(
PowerupSprite
::
PowerupNum
);
sp
=
new
PowerupSprite
(
svgrender
,
powerupelements
[
type
],
type
,
config
.
powerupLifeTime
);
field
.
addItem
(
sp
);
do
{
x
=
random
.
getLong
(
width
()
-
40
)
+
20
;
y
=
random
.
getLong
(
height
()
-
40
)
+
20
;
x
=
random
.
bounded
(
width
()
-
40
)
+
20
;
y
=
random
.
bounded
(
height
()
-
40
)
+
20
;
}
while
(((
x
-
width
()
/
2
)
*
(
x
-
width
()
/
2
)
+
(
y
-
height
()
/
2
)
*
(
y
-
height
()
/
2
))
<
(
50
*
50
));
sp
->
setPos
(
QPointF
(
x
,
y
));
...
...
mainview.h
View file @
253938a2
...
...
@@ -21,11 +21,11 @@
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QList>
#include <QRandomGenerator>
#include <QTimerEvent>
#include <QWidget>
#include <KRandomSequence>
class
KToggleAction
;
class
KActionCollection
;
class
QGraphicsSimpleTextItem
;
...
...
@@ -112,7 +112,7 @@ private:
QList
<
ExplosionSprite
*>
explosions
;
QList
<
PowerupSprite
*>
powerups
;
K
Random
Sequence
random
;
Q
Random
Generator
random
;
//Ai
Ai
*
ai
[
2
];
...
...
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