#include "ship.h"
#include <QDebug>
-Ship::Ship(QPixmap pixmap, QGraphicsItem *parent) :
- OrientationControlledGraphicsPixmapObject(pixmap,parent)
+Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
+ OrientationControlledGraphicsPixmapObject(pixmapList.at(0),parent)
{
+ shipImages_ = pixmapList;
ghostsAboard_ = 0;
}
// drop all ghosts when hitting an obstacle
emit droppingGhosts(ghostsAboard_);
ghostsAboard_ = 0;
+ updateShipImage();
return false;
}
else if (type == "ghost")
{
ghostsAboard_++;
+ updateShipImage();
qDebug() << ghostsAboard_ << " ghosts aboard";
}
}
+
+void Ship::updateShipImage()
+{
+ int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
+ setPixmap(shipImages_.at(index));
+}