Commit 253938a2 authored by Albert Astals Cid's avatar Albert Astals Cid

KRandomSequence -> QRandomGenerator

parent 3b43aefa
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)
......
......@@ -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);
}
......
......@@ -18,7 +18,7 @@
#ifndef __KSD_AI_H
#define __KSD_AI_H
#include <KRandomSequence>
#include <QRandomGenerator>
#include "dialogs.h"
#include "options.h"
......@@ -76,7 +76,7 @@ private:
SConfig *cfg;
KRandomSequence random;
QRandomGenerator random;
//actions
Rotation rotation;
......
......@@ -63,7 +63,7 @@ MyMainView::MyMainView(QWidget *parent)
{
int i,p;
setMinimumSize(600,400);
random.setSeed(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));
......
......@@ -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;
KRandomSequence random;
QRandomGenerator random;
//Ai
Ai *ai[2];
......
Markdown is supported
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