Spreading ghosts now handles situations where there is no free slot left
[ghostsoverboard] / mainwindow.cpp
index 8502b60..d292082 100644 (file)
@@ -1,4 +1,5 @@
 #include "mainwindow.h"
+#include "timercontrolledtursas.h"
 #include <QPixmap>
 #include <QTimer>
 #include <QDebug>
@@ -12,13 +13,13 @@ MainWindow::MainWindow(QWidget *parent)
 {
     paused_ = false;
 
-    pScene_ = new QGraphicsScene ();
+    pScene_ = new SeaScene ();
     pView_  = new QGraphicsView ();
 
     QPixmap waves (":/pix/meri.png");
     pScene_->setBackgroundBrush(QBrush(waves));
 
-    pTursas_ = new OrientationControlledGraphicsPixmapObject(QPixmap(":/pix/tursas.png"));
+    pTursas_ = new OrientationControlledGraphicsPixmapObject(QPixmap(":/pix/laiva.png"));
     pScene_->addItem(pTursas_);
 
     pView_->setScene(pScene_);
@@ -27,7 +28,7 @@ MainWindow::MainWindow(QWidget *parent)
 
     //the boundaries of the scene are set to match the size of the view window, which is not
     //available in the constructor --> timer needed
-    QTimer::singleShot(60,this,SLOT(initializeBoundaries()));
+    QTimer::singleShot(100,this,SLOT(initializeBoundaries()));
 
 
     QAction * pPauseAction = new QAction(tr("Pause"),this);
@@ -36,6 +37,23 @@ MainWindow::MainWindow(QWidget *parent)
     connect(pPauseAction,SIGNAL(triggered(bool)),this,SLOT(pause(bool)));
     menuBar()->addAction(pPauseAction);
 
+//    QGraphicsPixmapItem * pGhost = pScene_->addPixmap(QPixmap(":/pix/aave.png"));
+//    pGhost->setData(0,"ghost");
+    QGraphicsPixmapItem * pRock =  pScene_->addPixmap(QPixmap(":/pix/kari.png"));
+        QGraphicsPixmapItem * pRock2 =  pScene_->addPixmap(QPixmap(":/pix/kari.png"));
+    pRock->moveBy(40,40);
+    pRock->setData(0,"rock");
+    pRock2->moveBy(80,80);
+    pRock2->setData(0,"rock");
+
+    TimerControlledTursas * pMustekala = new TimerControlledTursas (QPixmap(":/pix/tursas.png"),100);
+    pScene_->addItem(pMustekala);
+    pMustekala->moveBy(100,100);
+    pMustekala->startMoving();
+
+
+
+
 }
 
 MainWindow::~MainWindow()
@@ -59,6 +77,8 @@ void MainWindow::initializeBoundaries()
     pTursas_->startMoving();
 
     qDebug() << "Initialized boundaries" << rectangle.left() << rectangle.right() << pView_->width();
+
+    pScene_->setupMap(5,5,5);
 }
 
 void MainWindow::pause(bool paused)