Now sets random seed
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Tue, 14 Jun 2011 08:23:07 +0000 (11:23 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Tue, 14 Jun 2011 08:23:07 +0000 (11:23 +0300)
And moved setting the background to the constructor of SeaScene.

mainwindow.cpp
seascene.cpp

index 1bbd123..6efb243 100644 (file)
@@ -16,8 +16,7 @@ MainWindow::MainWindow(QWidget *parent)
     pScene_ = new SeaScene ();
     pView_  = new QGraphicsView ();
 
-    QPixmap waves (":/pix/meri.png");
-    pScene_->setBackgroundBrush(QBrush(waves));
+
 
     pView_->setScene(pScene_);
     setCentralWidget(pView_);
index b6ba59b..fa2735f 100644 (file)
@@ -4,6 +4,7 @@
 #include <QGraphicsPixmapItem>
 #include <QDebug>
 #include <QMessageBox>
+#include <QTime>
 
 const QString ghostImageFilename_ = ":/pix/aave.png";
 const QString rockImageFilename_ =":/pix/kari.png";
@@ -13,7 +14,15 @@ const QString octopusImageFilename_= ":/pix/tursas.png";
 SeaScene::SeaScene(QObject *parent) :
     QGraphicsScene(parent)
 {
+    //set background
 
+    QPixmap waves (":/pix/meri.png");
+    waves.scaled(20,20);
+    setBackgroundBrush(QBrush(waves));
+
+    //set random seed
+
+    qsrand(QTime::currentTime().msec()+2);  //+2 to avoid setting it to 1
 
 }